@@ -51,13 +51,6 @@ In your Sphinx documentation ``conf.py``:
5151 " sphinx_github_changelog" ,
5252 ]
5353
54- # Provide a GitHub API token:
55- # Pass the SPHINX_GITHUB_CHANGELOG_TOKEN environment variable to your build
56- # OR
57- # You can retrieve your token any other way you want, but of course, please
58- # don't commit secrets to git, especially on a public repository
59- sphinx_github_changelog_token = ...
60-
6154 In your documentation:
6255
6356.. code-block :: restructuredtext
@@ -67,6 +60,12 @@ In your documentation:
6760 :github: https://github.com/you/your-project/releases/
6861 :pypi: https://pypi.org/project/your-project/
6962
63+ or more minimally (but not necessarily recommended):
64+
65+ .. code-block :: restructuredtext
66+
67+ .. changelog::
68+
7069
7170 See the end result for this project on ReadTheDocs __.
7271
@@ -139,27 +138,68 @@ draft GitHub Release and press "Publish Release". That's it.
139138Reference documentation
140139=======================
141140
141+ Automatic Configuration
142+ -----------------------
143+
144+ The extension can automatically detect the GitHub repository URL from your
145+ git remotes in this order:
146+
147+ 1. ``upstream `` remote
148+ 2. ``origin `` remote
149+
150+ The GraphQL API and GitHub root URL are derived from this URL.
151+
152+ If for any reason, you'd rather provide the repository explicitly (e.g. the doc
153+ repo doesn't match the repo you're releasing from, or anything else), you can
154+ define the ``:github: `` attribute to the directive. See directive _ for
155+ details.
156+
157+
158+ Authentication
159+ --------------
160+
161+ The extension uses the GitHub GraphQL API to retrieve the changelog. This
162+ requires authentication using a GitHub API token.
163+
164+ However if you use git over HTTPS, or the ``gh `` CLI, you probably already have a
165+ suitable token, which ``sphinx-github-changelog `` will automatically use.
166+
167+ In CI like GitHub Actions you can pass a token explicitly as an environment
168+ variable:
169+
170+ .. code-block :: yaml
171+
172+ - name : Build documentation
173+ run : make html
174+ env :
175+ SPHINX_GITHUB_CHANGELOG_TOKEN : ${{ github.token }}
176+
177+ In remaining cases you may need to create a personal access token. If the
178+ repository is public, the token doesn't need any special access (you can
179+ uncheck eveything). For private and internal repositories, the token must
180+ have ``repo `` scope (classic tokens) or ``contents: read `` access (fine-grained
181+ tokens).
182+
183+ Pass the token as the ``SPHINX_GITHUB_CHANGELOG_TOKEN `` environment variable.
184+ You can also set the token as ``sphinx_github_changelog_token `` in ``conf.py ``
185+ but you should never commit secrets such as this.
186+
187+
142188Extension options (``conf.py ``)
143189-------------------------------
144190
145- - ``sphinx_github_changelog_token ``: GitHub API token.
146- If the repository is public, the token doesn't need any special access (you
147- can uncheck eveything). If the repository is private, you'll need to give
148- your token enough access to read the releases. Defaults to the value of the
149- environment variable ``SPHINX_GITHUB_CHANGELOG_TOKEN ``. If no value is
150- provided, the build will still pass but the changelog will not be built, and
151- a link to the ``changelog-url `` will be displayed (if provided).
191+ - ``sphinx_github_changelog_token ``: GitHub API token, if needed.
152192
153- - ``sphinx_github_changelog_root_repo `` (optional): Root url to the repository,
154- defaults to "https://github.com/". Useful if you're using a self-hosted GitHub
155- instance.
193+ Two options are accepted for backwards compatibility, but are likely detected
194+ automatically from the ``:github: `` parameter to the directive:
156195
157- - ``sphinx_github_changelog_graphql_url `` (optional): Url to graphql api, defaults
158- to "https://api.github.com/graphql". Useful if you're using a self-hosted GitHub
159- instance.
196+ - ``sphinx_github_changelog_root_repo `` (optional): Root URL to the repository.
197+ - ``sphinx_github_changelog_graphql_url `` (optional): URL to GraphQL API.
160198
161199.. _ReadTheDocs : https://readthedocs.org/
162200
201+ .. _directive :
202+
163203Directive
164204---------
165205
@@ -173,7 +213,8 @@ Directive
173213 Attributes
174214~~~~~~~~~~
175215
176- - ``github `` (**required **): URL to the releases page of the repository.
216+ - ``github `` (optional): URL to the releases page of the repository.
217+ If not provided, auto‑detected from your git remote, as described above.
177218- ``changelog-url `` (optional): URL to the built version of your changelog.
178219 ``sphinx-github-changelog `` will display a link to your built changelog if the GitHub
179220 token is not provided (hopefully, this does not happen in your built documentation)
0 commit comments