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

[Doc] Add github links for source code references #10672

Merged
merged 4 commits into from
Dec 3, 2024

Conversation

russellb
Copy link
Collaborator

Previously, the use of sphinx.ext.viewcode generated new pages that
included the raw source code. This change adds the
sphinx.ext.linkcode extension, which allows defining a custom method
for generating source code URLs given a code reference. This now
includes links to the appropriate file and line number on github for
code references.

For now I left the viewcode extension in place. The result is that
code references now have 2 [source] links - one for the copy of the
source in the docs, and one to github. If the github links seem to
work well enough, we can drop viewcode later.

Signed-off-by: Russell Bryant [email protected]

Previously, the use of `sphinx.ext.viewcode` generated new pages that
included the raw source code. This change adds the
`sphinx.ext.linkcode` extension, which allows defining a custom method
for generating source code URLs given a code reference. This now
includes links to the appropriate file and line number on github for
code references.

For now I left the `viewcode` extension in place. The result is that
code references now have 2 `[source]` links - one for the copy of the
source in the docs, and one to github. If the github links seem to
work well enough, we can drop `viewcode` later.

Signed-off-by: Russell Bryant <[email protected]>
Copy link

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can do one of these:

  • Add ready label to the PR
  • Enable auto-merge.

🚀

@mergify mergify bot added the documentation Improvements or additions to documentation label Nov 26, 2024
@DarkLight1337
Copy link
Member

Hmm, the links don't work inside PR builds. I think we should fallback to main branch in this case.

@russellb
Copy link
Collaborator Author

Hmm, the links don't work inside PR builds. I think we should fallback to main branch in this case.

good catch! I'll fix this. I'll also see if I can make it work for PR builds properly.

@russellb russellb marked this pull request as draft November 26, 2024 14:46
@russellb russellb force-pushed the docs-github branch 4 times, most recently from dcf7a38 to 531135d Compare November 26, 2024 18:17
Make github source link generation work for PR doc builds, as well.

This also fixes link generation for class members, which was failing
before.

Signed-off-by: Russell Bryant <[email protected]>
@russellb russellb marked this pull request as ready for review November 26, 2024 19:10
@russellb
Copy link
Collaborator Author

@DarkLight1337 PR build seems to be working now

@DarkLight1337
Copy link
Member

Looks good overall. There is still one failing case, vllm.multimodal.MULTIMODAL_REGISTRY: https://vllm--10672.org.readthedocs.build/en/10672/design/multimodal/multimodal_index.html#registry

inspect doesn't support getting the file and line number for a
reference to an instance of a class. We can get the class and provide
a link to that, instead. That's better than nothing.

This improves the result for `vllm.multimodal.MULTIMODAL_REGISTRY`.

Signed-off-by: Russell Bryant <[email protected]>
@russellb
Copy link
Collaborator Author

russellb commented Dec 2, 2024

Looks good overall. There is still one failing case, vllm.multimodal.MULTIMODAL_REGISTRY: https://vllm--10672.org.readthedocs.build/en/10672/design/multimodal/multimodal_index.html#registry

Thanks. I just improved this one. It's a link to the class MultiModalRegistry instead of the specific instance of that class, MULTIMODAL_REGISTRY, because inspect raises an exception if you pass it an instance of a class. This isn't perfect, but it's better than what it did before with a totally broken link.

@DarkLight1337 DarkLight1337 added the ready ONLY add when PR is ready to merge/full CI is needed label Dec 3, 2024
Signed-off-by: DarkLight1337 <[email protected]>
Copy link
Member

@DarkLight1337 DarkLight1337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works now, thanks for spending the time and effort on polishing this!

@DarkLight1337 DarkLight1337 enabled auto-merge (squash) December 3, 2024 04:03
@DarkLight1337 DarkLight1337 merged commit ef51831 into vllm-project:main Dec 3, 2024
33 checks passed
sleepwalker2017 pushed a commit to sleepwalker2017/vllm that referenced this pull request Dec 13, 2024
Signed-off-by: Russell Bryant <[email protected]>
Signed-off-by: DarkLight1337 <[email protected]>
Co-authored-by: DarkLight1337 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants