Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] New guidelines for referencing and linking to source code #1926

Closed
willihay opened this issue Aug 22, 2022 · 1 comment · Fixed by #2403
Closed

[DOCS] New guidelines for referencing and linking to source code #1926

willihay opened this issue Aug 22, 2022 · 1 comment · Fixed by #2403
Assignees
Labels
kind/contributing priority/major Major priority. Work that should be handled after all blocking and critical work is done. triage/accepted Indicates an issue or PR is ready to be actively worked on.

Comments

@willihay
Copy link
Contributor

willihay commented Aug 22, 2022

Describe the issue briefly

There's nothing in the Contributor Style Guide as of yet regarding a standard format for references and links to O3DE source code. Contributors have used a variety of formats in the O3DE User Guide. To promote consistency, we should provide some guidelines in the Contributor Guide.

Which page(s) / section(s) are affected?

Links style

In this section on Formatting, various styles for links are presented. I recommend that we divide this into Docs links - which would contain the styles currently mentioned - and Source code links. Under source code links, I recommend the following guidelines:

New guideline on source code links

When linking to specific files or line numbers in source code, use permalinks whenever possible.

File link example:

[Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp](https://github.com/o3de/o3de/blob/14c366cabc906ac1367492c457959333c2eaafc5/Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp)

Result:

Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp

To link to a specific section of the source file, such as a function or a line of code, include line numbers in the URL. It's preferable to describe the section using words instead of line numbers because line numbers can easily change. While a permalink will always be valid, a line number range in the link label can be misleading if those lines have changed in more recent versions of the source code.

File section link example:

[Reflect function calls in Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp](https://github.com/o3de/o3de/blob/14c366cabc906ac1367492c457959333c2eaafc5/Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp#L118-L122)

Result:

Reflect function calls in Gems/StartingPointInput/Code/Source/StartingPointInputGem.cpp

To obtain permalinks for a file in a GitHub repo, navigate to the Code tab and open the file, then choose Copy permalink from the ... menu:

image

To obtain permalinks for specific lines of code in a file in a GitHub repo:

  1. Navigate to the Code tab and open the file.
  2. Click on the first line number in the block.
  3. Shift+click on the last line number in the block.
  4. Choose Copy permalink from the ... menu to the left of the first line number:

image

Alternatively, you can just manually add the line number range to the end of the file's permalink URL, using the format: #Lnnn-Lnnn, where nnn represents a line number.

@willihay willihay added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Aug 22, 2022
@willihay willihay self-assigned this Aug 22, 2022
@willihay
Copy link
Contributor Author

Issue created from discussion o3de/sig-docs-community#47

@FiniteStateGit FiniteStateGit added triage/accepted Indicates an issue or PR is ready to be actively worked on. kind/contributing and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Aug 24, 2022
@chanmosq chanmosq added the priority/major Major priority. Work that should be handled after all blocking and critical work is done. label Mar 14, 2023
@chanmosq chanmosq moved this from Backlog to To do in O3DE - Docs and Community Roadmap Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/contributing priority/major Major priority. Work that should be handled after all blocking and critical work is done. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Development

Successfully merging a pull request may close this issue.

3 participants