epythet.repo_links¶
Point repo-relative README links at the repository, so they work on the site.
The landing page is the project README included verbatim. A README written for
GitHub links to repo files that are not site pages (misc/docs/design.md,
LICENSE, examples/); on the built site such a link is a dead relative
URL. resolve_repo_link() turns one into a blob/tree URL on the
project’s repository, and the doctree-resolved hook in
epythet.sphinx_ext applies it to the landing page.
>>> resolve_repo_link("misc/docs/a.md", ["misc/docs/a.md"], "https://github.com/o/r")
'https://github.com/o/r/blob/HEAD/misc/docs/a.md'
>>> resolve_repo_link("https://x.org/a", [], "https://github.com/o/r") is None
True
Module Attributes
GitHub resolves |
Functions
|
The repository URL for a repo-relative |
- epythet.repo_links.DEFAULT_REF = 'HEAD'¶
GitHub resolves
HEADto the default branch.- Type:
The ref used in generated URLs
- epythet.repo_links.resolve_repo_link(refuri, repo_paths, repo_url, *, ref='HEAD')[source]¶
The repository URL for a repo-relative
refuri, orNoneto leave it alone.- Parameters:
refuri (
str) – the link target as written in the READMErepo_paths (
Container[str]) – the posix paths (files and directories, relative to the project root) that exist; a link is rewritten only when it names onerepo_url (
str) – the repository’s web URL (https://github.com/owner/repo)ref (
str) – the git ref the URL points at
- Return type: