Skip to content

Commit

Permalink
doc: enable source links in examples
Browse files Browse the repository at this point in the history
This is a bit more convoluted than usual, because we want documentation
built for tagged releases to point at the source code for the release,
and master otherwise. We rely on version having a '.dev0' suffix (or
'.<anything>', really) once we've deviated from the latest release.

The first formatting pass also requires us to wrap {source} and {line}
in extra {}'s.
  • Loading branch information
jnikula committed Oct 25, 2023
1 parent bc87830 commit 79bc1e2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@

hawkmoth_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../test/examples')

source_uri = 'https://github.com/jnikula/hawkmoth/tree/{version}/test/examples/{{source}}#L{{line}}'
source_version = f'v{version}' if len(version.split('.')) == 3 else 'master'

hawkmoth_source_uri = source_uri.format(version=source_version)

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

Expand Down

0 comments on commit 79bc1e2

Please sign in to comment.