Skip to content

Commit 9fcbd3d

Browse files
committed
Generate READMEs with sphinx-readme
1 parent 493819d commit 9fcbd3d

10 files changed

+269
-371
lines changed

README.rst

Lines changed: 93 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,65 @@
1+
.. |.~.get_linkcode_resolve| replace:: ``get_linkcode_resolve()``
2+
.. _.~.get_linkcode_resolve: https://sphinx-github-style.readthedocs.io/en/latest/modules.html#sphinx_github_style.__init__.get_linkcode_resolve
3+
.. |linkcode_blob| replace:: ``linkcode_blob``
4+
.. _linkcode_blob: https://sphinx-github-style.readthedocs.io/en/latest/index.html#confval-linkcode_blob
5+
.. |linkcode_link_text| replace:: ``linkcode_link_text``
6+
.. _linkcode_link_text: https://sphinx-github-style.readthedocs.io/en/latest/index.html#confval-linkcode_link_text
7+
.. |linkcode_resolve| replace:: ``linkcode_resolve``
8+
.. _linkcode_resolve: https://sphinx-github-style.readthedocs.io/en/latest/index.html#confval-linkcode_resolve
9+
.. |linkcode_url| replace:: ``linkcode_url``
10+
.. _linkcode_url: https://sphinx-github-style.readthedocs.io/en/latest/index.html#confval-linkcode_url
11+
.. |sphinx+html_context| replace:: ``html_context``
12+
.. _sphinx+html_context: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_context
13+
.. |.sphinx.ext.linkcode| replace:: ``sphinx.ext.linkcode``
14+
.. _.sphinx.ext.linkcode: https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html#module-sphinx.ext.linkcode
15+
.. |.sphinx.ext.viewcode| replace:: ``sphinx.ext.viewcode``
16+
.. _.sphinx.ext.viewcode: https://www.sphinx-doc.org/en/master/usage/extensions/viewcode.html#module-sphinx.ext.viewcode
17+
.. |top_level| replace:: ``top_level``
18+
.. _top_level: https://sphinx-github-style.readthedocs.io/en/latest/index.html#confval-top_level
19+
120
.. Title: Sphinx Github Style
221
.. Description: A Sphinx extension to add GitHub source code links and syntax highlighting
322
.. Author: TDKorn (Adam Korn)
423
524
.. meta::
625
:title: Sphinx Github Style
726
:description: A Sphinx extension to add GitHub source code links and syntax highlighting
8-
9-
.. |.get_linkcode_resolve| replace:: ``get_linkcode_resolve()``
10-
.. _.get_linkcode_resolve: https://github.com/TDKorn/sphinx-github-style/blob/v1.0.5/sphinx_github_style/__init__.py#L148-L214
11-
.. |.add_linkcode_node_class| replace:: ``add_linkcode_node_class()``
12-
.. _.add_linkcode_node_class: https://github.com/TDKorn/sphinx-github-style/blob/v1.0.5/sphinx_github_style/add_linkcode_class.py#L9-L24
13-
.. |.TDKStyle| replace:: ``TDKStyle``
14-
.. _.TDKStyle: https://github.com/TDKorn/sphinx-github-style/blob/v1.0.5/sphinx_github_style/github_style.py#L44-L139
15-
.. |.TDKMethLexer| replace:: ``TDKMethLexer``
16-
.. _.TDKMethLexer: https://github.com/TDKorn/sphinx-github-style/blob/v1.0.5/sphinx_github_style/meth_lexer.py#L27-L42
27+
28+
1729
.. |.github_style| replace:: ``github_style.css``
18-
.. _.github_style: https://github.com/tdkorn/sphinx-github-style/blob/v1.0.5/sphinx_github_style/_static/github_style.css
19-
.. |RTD| replace:: ReadTheDocs
20-
.. _RTD: https://sphinx-github-style.readthedocs.io/en/latest/
21-
.. |docs| replace:: **Explore the docs »**
22-
.. _docs: https://sphinx-github-style.readthedocs.io/en/latest/
30+
.. _.github_style: https://github.com/tdkorn/sphinx-github-style/tree/v1.0.4/sphinx_github_style/_static/github_style.css
31+
32+
33+
2334

2435

2536
.. raw:: html
2637

2738
<div align="center">
2839

2940

30-
.. image:: docs/source/_static/logo_square_grey_blue.png
41+
.. image:: https://raw.githubusercontent.com/TDKorn/sphinx-github-style/master/docs/source/_static/logo_square_grey_blue.png
3142
:alt: Sphinx GitHub Style: GitHub Integration and Pygments Style for Sphinx Documentation
3243
:width: 25%
3344

45+
46+
3447
.. raw:: html
3548

3649
<h1>Sphinx Github Style</h1>
3750

38-
GitHub source code links and syntax highlighting for Sphinx docs
51+
52+
GitHub source code links and syntax highlighting for Sphinx documentation
53+
54+
55+
.. |docs| replace:: **Explore the docs »**
56+
.. _docs: https://sphinx-github-style.readthedocs.io/en/latest/
3957

4058
|docs|_
4159

60+
61+
62+
4263
.. image:: https://img.shields.io/pypi/v/sphinx-github-style?color=eb5202
4364
:target: https://pypi.org/project/sphinx-github-style/
4465
:alt: PyPI Version
@@ -61,63 +82,73 @@ GitHub source code links and syntax highlighting for Sphinx docs
6182
<br/>
6283

6384

85+
6486
About
6587
~~~~~~~~~~~~~
6688

67-
``sphinx-github-style`` is a Sphinx extension that makes your docs look like and link to GitHub
89+
``sphinx-github-style`` is a Sphinx extension that links your documentation to GitHub source code.
90+
It also adds syntax highlighting for code blocks similar to GitHub's pretty lights dark theme.
6891

6992
...
7093

94+
7195
GitHub Source Code Links
7296
===============================
7397

74-
.. |linkcode| replace:: ``sphinx.ext.linkcode``
75-
.. _linkcode: https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html
7698

77-
**Using** |linkcode|_, a ``View on GitHub`` **link is added to the documentation of every class, method and function:**
99+
Using |.sphinx.ext.linkcode|_, a ``View on GitHub`` link is added to the documentation of every class, method, function, and property:
78100

79-
.. image:: https://user-images.githubusercontent.com/96394652/220941352-f5530a56-d338-4b90-b83a-4b22b0f632fe.png
80-
:alt: sphinx github style adds a "View on GitHub" link
81101

82-
**They link to and highlight the corresponding code block in your GitHub repo:**
83102

84-
.. image:: https://user-images.githubusercontent.com/96394652/220945912-447173db-2ac7-4e00-bec5-3859753bf687.png
85103

86104

87-
|
105+
.. image:: https://raw.githubusercontent.com/TDKorn/sphinx-github-style/master/docs/source/_static/github_link.png
106+
:alt: sphinx-github-style adds a "View on GitHub" link
107+
108+
109+
They link to and highlight the corresponding code block in your GitHub repository:
110+
111+
112+
113+
.. image:: https://raw.githubusercontent.com/TDKorn/sphinx-github-style/master/docs/source/_static/github_linked_code.png
114+
:alt: The linked corresponding highlighted source code block on GitHub
115+
116+
88117

89118
.. raw:: html
90119

91120
<table>
92-
<tr align="left">
93-
<th>📝 Note</th>
94-
</tr>
95-
<tr>
96-
<td>
121+
<tr align="left">
122+
<th>
97123

98-
These links can be used with/instead of the links added by ``sphinx.ext.viewcode``
124+
📝 Note
99125

100-
* They use a newly added ``linkcode-link`` class which can be styled using CSS
126+
.. raw:: html
127+
128+
</th>
129+
<tr><td>
101130

131+
These links can be `styled with CSS <https://sphinx-github-style.readthedocs.io/en/latest/add_linkcode_class.html>`_ and used with/instead
132+
of the links added by |.sphinx.ext.viewcode|_
102133

103134
.. raw:: html
104135

105136
</td></tr>
106137
</table>
107138

108139

109-
|
110140

111141
Syntax Highlighting
112142
====================
113143

114-
``sphinx-github-style`` **also contains a** ``Pygments`` **style to highlight code in your documentation similar to GitHub:**
144+
``sphinx-github-style`` also contains a ``Pygments`` style to highlight code blocks similar to GitHub:
115145

116146

117-
.. image:: https://user-images.githubusercontent.com/96394652/220946796-bf7aa236-964d-48e7-83e2-142aac00b0dd.png
147+
148+
.. image:: https://raw.githubusercontent.com/TDKorn/sphinx-github-style/master/docs/source/_static/syntax_highlighting.png
149+
:alt: A code block highlighted by the Pygments style. It looks identical to GitHub.
118150

119151

120-
|
121152

122153
Installation
123154
~~~~~~~~~~~~~~~~
@@ -126,7 +157,6 @@ To install using ``pip``::
126157

127158
pip install sphinx-github-style
128159

129-
|
130160

131161
Configuration
132162
~~~~~~~~~~~~~~~
@@ -139,93 +169,58 @@ Add the extension to your ``conf.py``
139169
"sphinx_github_style",
140170
]
141171
142-
...
143-
144172
Optional Configuration Variables
145173
===================================
146174

147175
Add any (or none) of the following configuration variables to your ``conf.py``
148176

149177

150-
``top_level``
151-
^^^^^^^^^^^^^^^^^^^
152-
153-
.. code-block:: python
154-
155-
top_level: str
156-
157-
The name of the package's top-level module. For this repo, it would be ``sphinx_github_style``
158-
159-
...
160-
161-
162-
``linkcode_blob``
163-
^^^^^^^^^^^^^^^^^^^
164-
165-
.. code-block:: python
166-
167-
linkcode_blob: str = "head"
168-
169178

170-
The blob to link to on GitHub - any of ``"head"``, ``"last_tag"``, or ``"{blob}"``
171179

172-
* ``head`` (default): links to the most recent commit hash; if this commit is tagged, uses the tag instead
173-
* ``last_tag``: links to the most recent commit tag on the currently checked out branch
174-
* ``blob``: links to any blob you want, for example ``"master"`` or ``"v2.0.1"``
180+
|top_level|_
181+
The name of the package's top-level module. For this repo, it would be ``sphinx_github_style``
175182

183+
**Type:** ``str``
176184

177-
...
178-
179-
``linkcode_url``
180-
^^^^^^^^^^^^^^^^^^^
181-
182-
.. code-block:: python
183-
184-
linkcode_url: str = f"https://github.com/{html_context['github_user']}/{html_context['github_repo']}/{html_context['github_version']}"
185-
186-
The link to your GitHub repository formatted as ``https://github.com/user/repo``
185+
|
187186
188-
* If not provided, will attempt to create the link from the ``html_context`` dict
187+
|linkcode_blob|_
188+
The blob to link to on GitHub - any of ``"head"``, ``"last_tag"``, or ``"{blob}"``
189189

190-
...
190+
**Type:** ``str``
191191

192-
``linkcode_link_text``
193-
^^^^^^^^^^^^^^^^^^^^^^
192+
**Default:** ``"head"``
194193

195-
.. code-block:: python
194+
* ``"head"`` (default): links to the most recent commit hash; if this commit is tagged, uses the tag instead
195+
* ``"last_tag"``: links to the most recent commit tag on the currently checked out branch
196+
* ``"blob"``: links to any blob you want, for example ``"master"`` or ``"v2.0.1"``
196197

197-
linkcode_link_text: str = "View on GitHub"
198+
|
198199
200+
|linkcode_url|_
201+
The link to your GitHub repository formatted as ``https://github.com/user/repo``
199202

200-
The text to use for the linkcode link
203+
**Type:** ``str``
201204

202-
...
205+
**Default:** ``f"https://github.com/{html_context['github_user']}/{html_context['github_repo']}/{html_context['github_version']}"``
203206

204-
``linkcode_resolve``
205-
^^^^^^^^^^^^^^^^^^^^^^^^
207+
* If not provided, will attempt to create the link from the |sphinx+html_context|_ dict
206208

207-
.. code-block:: python
209+
|
208210
209-
linkcode_resolve: Callable
211+
|linkcode_link_text|_
212+
The text to use for the linkcode link
210213

211-
A ``linkcode_resolve()`` function to use for resolving the link target
214+
**Type:** ``str``
212215

213-
* Uses default function from |.get_linkcode_resolve|_ if not specified (recommended)
216+
**Default:** ``"View on GitHub"``
214217

215218
|
216219
217-
Noteworthy Components
218-
~~~~~~~~~~~~~~~~~~~~~
219-
220-
* |.TDKStyle|_ - Pygments Style for syntax highlighting similar to Github Pretty Lights Dark Theme
221-
* |.TDKMethLexer|_ - Pygments Lexor to add syntax highlighting to methods
222-
* |.get_linkcode_resolve|_ - to link to GitHub source code using ``sphinx.ext.linkcode``
223-
* |.add_linkcode_node_class|_ - adds a new ``linkcode-link`` class, allowing for CSS styling separately from ``viewcode`` links
224-
* |.github_style|_ - CSS styling for linkcode links (icon + text)
220+
|linkcode_resolve|_
221+
A ``linkcode_resolve()`` function to use when resolving the link target with |.sphinx.ext.linkcode|_
225222

226-
|
223+
**Type:** ``Callable``
227224

228-
Documentation
229-
~~~~~~~~~~~~~~~~
225+
**Default:** Return value from |.~.get_linkcode_resolve|_
230226

231-
Full documentation can be found on |RTD|_

0 commit comments

Comments
 (0)