Establish and use a single pattern for source code references.
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
## Description of the problem / feature request:
Our code and docs contain pointers to our code. For consistency, we should use a single format, but do not. For example, [aquery.html](https://github.com/bazelbuild/bazel/blob/4e9a77e2d2aeb28cd300304fc703e8fb2b59c9d3/site/docs/aquery.html) uses 3 different formats.
```
href="https://github.com/bazelbuild/bazel/tree/master/tools/aquery_differ
href="https://source.bazel.build/bazel/+/master:src/main/java/com/google/devtools/build/lib/actions/Actions.java;l=59;drc=146d51aa1ec9dcb721a7483479ef0b1ac21d39f1
href="https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/actions/ActionAnalysisMetadata.java;l=89;drc=8b856f5484f0117b2aebc302f849c2a15f273310
```
Further compounding the problem is that many links are incorrect, because they refer to a line number, but not at any fixed revision.
## Possible Requirements
- Should we standardize on one repository to point to?
- Of course yes.
- Which one?
- github is obviously correct because that is where the code is hosted
- opensource.google.com has better functionality.
- What is the meaning of a permalink to a line of code?
- should we allow that in user documentation or only within code?
- My vote would be only within code. End user docs should not require Bazel source to understand. (@floriographygoth - thoughts?)
- even within code, is a permalink useful when it can go stale?
- should we use query patterns rather than line numbers?
- should permalinks point to the default branch (master, but soon to be main) or to HEAD?
- pointing to the branch allows the link to stay within the branch when we do development in LTS branches.
- but when you write the code in main and then you are browsing on an LTS branch, you get sent to the main branch rather than the branch you work in. So that is a fail
- if we point to HEAD, then do you get the most recent commit on the branch you are viewing for?
- that seems right.
- I do not know if it works
- How does this play with examples and LTS?
- Versioned documentation may want to point to an examples repository (code, but not bazelbuild/bazel code) with URLS.
- So we have similar questions.
- I believe if is generally sufficient to only do references of the form "See the frobnitz example" where we have a link to https://github.com/bazelbuild/examples/blob//...
- That is. Always be careful to use the branch name because we need an examples branch to go with each LTS branch, and do not point to much at individual lines. The examples should only do that within themselves.
## Proposal
- Answer the questions above
- Publish the rules in the overall contribution/coding standards guide
- Align the world
As a first step, my presumption is
- Point to github.com
- Remove references to code in end user documentation
- In technical docs for how to work on Bazel we should point to files only
- syntax: ... See the `frobnitz` function in `` (or to main if we make that choice)
- Within code
- Favor query for functions rather than links to lines
- If you MUST point to a specific version or line. Use the github commit in the URL
Contributor guide
Assessment
This issue has not been assessed yet.