Open jrouly opened 2 months ago
Hm, I've never used the substitution, and I don't have a large experience in sphinx, so it's hard to say. I don't know if it's a good idea to make it work that way: the idea of requesting the user to put the link this way is so that if we display this page on GitHub (where it won't be processed by Sphinx), there's at least a usable link to the changelog source.
An alternative would be to allow removing the link altogether and set the default value for all changelog elements in conf.py. This way, you wouldn't have to use your substitution.
This would require a PR to the project.
@ewjoachim I ended up coming to a similar conclusion. My implementation (which ended up working) is to specialize the directive provided by this plugin to allow for programmatic specification of the changelog elements (specifically the GitHub URL).
from sphinx_github_changelog.changelog import ChangelogDirective
# Set the GitHub Token from the environment so the extension can pull the latest releases.
repo_link = os.environ.get("WHATEVER", "no-repo-link")
# Customize the extension directive so the repo link can be pulled from the environment, rather than from static RST.
class CustomChangelogDirective(ChangelogDirective):
def run(self):
self.options["github"] = f"{repo_link}/releases"
return super().run()
def setup(app):
# Override the Sphinx GitHub Changelog directive with our customized directive.
app.add_directive("changelog", CustomChangelogDirective)
Changelog
---------
.. changelog::
I agree a PR could be contributed to this project to allow the directive to read options programmatically or via RST out of the box, without requiring downstream specialization.
I agree a PR could be contributed to this project
Would you be interested in crafting such a PR ? :D
I have the following substitutions defined in my
rst_prolog
inconf.py
:where the
repo_link
is set from an environment variable. I want to use this in myindex.rst
as below:but it seems like the literal string
|repo_link|
is what's getting processed by the sphinx-github-changelog extension, rather than the substituted value coming in fromrst_prolog
/rst_epilog
.I'm a pretty new sphinx/rst user, so not really sure where to go from here.