1
- .. |.linkcode_resolve | replace :: ``linkcode_resolve() ``
2
- .. _.linkcode_resolve : :func:`~.linkcode_resolve`
1
+ .. Title: Sphinx Github Style
2
+ .. Description: A Sphinx extension to add GitHub source code links and syntax highlighting
3
+ .. Author: TDKorn (Adam Korn)
4
+
5
+ .. |.get_linkcode_resolve | replace :: ``get_linkcode_resolve() ``
6
+ .. _.get_linkcode_resolve : https://github.com/TDKorn/sphinx-github-style/blob/v1.0.0/sphinx_github_style/__init__.py#L150-L207
3
7
.. |.add_linkcode_node_class | replace :: ``add_linkcode_node_class() ``
4
- .. _.add_linkcode_node_class : :func:`~.add_linkcode_node_class`
8
+ .. _.add_linkcode_node_class : https://github.com/TDKorn/sphinx-github-style/blob/v1.0.0/sphinx_github_style/add_linkcode_class.py#L9-L24
9
+ .. |.TDKStyle | replace :: ``TDKStyle ``
10
+ .. _.TDKStyle : https://github.com/TDKorn/sphinx-github-style/blob/v1.0.0/sphinx_github_style/github_style.py#L44-L139
11
+ .. |.TDKMethLexor | replace :: ``TDKMethLexor ``
12
+ .. _.TDKMethLexor : https://github.com/TDKorn/sphinx-github-style/blob/v1.0.0/sphinx_github_style/meth_lexer.py#L28-L43
13
+ .. |.github_style | replace :: ``github_style.css ``
14
+ .. _.github_style : https://github.com/tdkorn/sphinx-github-style/blob/v1.0.0/sphinx_github_style/_static/github_style.css
15
+ .. |RTD | replace :: ReadTheDocs
16
+ .. _RTD : https://sphinx-github-style.readthedocs.io/en/latest/
17
+ .. |docs | replace :: **Explore the docs » **
18
+ .. _docs : https://sphinx-github-style.readthedocs.io/en/latest/
5
19
6
20
7
21
.. raw :: html
10
24
11
25
12
26
.. image :: docs/source/_static/logo_square_grey_blue.png
13
- :alt: Sphinx GitHub Style: Magento 2 REST API wrapper
27
+ :alt: Sphinx GitHub Style: GitHub Integration and Pygments Style for Sphinx Documentation
14
28
:width: 25%
15
29
16
30
.. raw :: html
17
31
18
32
<h1 >sphinx-github-style</h1 >
19
33
34
+ GitHub source code links and syntax highlighting for Sphinx docs
20
35
21
-
22
- .. |RTD|_
36
+ |docs |_
23
37
24
38
.. image :: https://img.shields.io/pypi/v/sphinx-github-style?color=eb5202
25
39
:target: https://pypi.org/project/sphinx-github-style/
26
40
:alt: PyPI Version
27
41
28
- .. image :: https://img.shields.io/badge/GitHub-sphinx--github--theme -4f1abc
29
- :target: https://github.com/tdkorn/sphinx-github-style
42
+ .. image :: https://img.shields.io/badge/GitHub-sphinx--github--style -4f1abc
43
+ :target: https://github.com/tdkorn/sphinx-github-style/
30
44
:alt: GitHub Repository
31
45
32
46
.. image :: https://static.pepy.tech/personalized-badge/sphinx-github-style?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads
33
- :target: https://pepy.tech/project/my-magento
47
+ :target: https://pepy.tech/project/sphinx-github-style/
34
48
35
49
.. image :: https://readthedocs.org/projects/sphinx-github-style/badge/?version=latest
36
50
:target: https://sphinx-github-style.readthedocs.io/en/latest/?badge=latest
44
58
45
59
46
60
About
47
- ~~~~~~~~~
61
+ ~~~~~~~~~~~~~
62
+
63
+ ``sphinx-github-style `` is a Sphinx extension that makes your docs look like and link to GitHub
64
+
65
+ ...
48
66
49
- `` sphinx-github-style `` is a
50
- Sphinx extension that adds GitHub source code links and syntax highlighting to your documentation
67
+ GitHub Source Code Links
68
+ ===============================
51
69
52
- Sample
53
- ========
70
+ .. | linkcode | replace :: `` sphinx.ext.linkcode ``
71
+ .. _ linkcode : https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html
54
72
55
- A "View on GitHub" link will be added to your API documentation.
56
- It can be used in addition to or instead of the links added by ``sphinx.ext.viewcode ``:
73
+ **Using ** |linkcode |_, a ``View on GitHub `` **link is added to the documentation of every class, method and function: **
57
74
58
- .. image :: https://user-images.githubusercontent.com/96394652/220267328-76b573ea-1c18-4490-9eaf-36ed9ca5a9c0 .png
75
+ .. image :: https://user-images.githubusercontent.com/96394652/220941352-f5530a56-d338-4b90-b83a-4b22b0f632fe .png
59
76
:alt: sphinx github style adds a "View on GitHub" link
60
77
61
- These link to the highlighted code in your GitHub repo:
78
+ **They link to and highlight the corresponding code block in your GitHub repo: **
79
+
80
+ .. image :: https://user-images.githubusercontent.com/96394652/220945912-447173db-2ac7-4e00-bec5-3859753bf687.png
81
+
82
+
83
+ |
84
+
85
+ .. raw :: html
86
+
87
+ <table >
88
+ <tr align =" left" >
89
+ <th >📝 Note</th >
90
+ </tr >
91
+ <tr >
92
+ <td >
93
+
94
+ These links can be used with/instead of the links added by ``sphinx.ext.viewcode ``
95
+
96
+ * They use a newly added ``linkcode-link `` class which can be styled using CSS
97
+
98
+
99
+ .. raw :: html
100
+
101
+ </td ></tr >
102
+ </table >
103
+
62
104
63
- .. parse gh code
64
- .. image :: https://user-images.githubusercontent.com/96394652/220267628-10cbda6d-7f51-4e66-bdff-23410cbfacc4.png
105
+ |
65
106
107
+ Syntax Highlighting
108
+ ====================
66
109
67
- ``sphinx-github-style `` also contains a Pygments style to highlight code blocks in your documentation similar to GitHub's syntax highlighting dark theme:
110
+ ``sphinx-github-style `` ** also contains a ** `` Pygments `` ** style to highlight code in your documentation similar to GitHub: **
68
111
69
- .. parse docs code
70
- .. image :: https://user-images.githubusercontent.com/96394652/220267065-f371a152-0abe-402e-b350-d5171d933931.png
71
112
113
+ .. image :: https://user-images.githubusercontent.com/96394652/220946796-bf7aa236-964d-48e7-83e2-142aac00b0dd.png
114
+
115
+
116
+ |
72
117
73
118
Installation
74
119
~~~~~~~~~~~~~~~~
@@ -77,6 +122,7 @@ To install using ``pip``::
77
122
78
123
pip install sphinx-github-style
79
124
125
+ |
80
126
81
127
Configuration
82
128
~~~~~~~~~~~~~~~
@@ -89,76 +135,80 @@ Add the extension to your ``conf.py``
89
135
" sphinx_github_style" ,
90
136
]
91
137
138
+ ...
92
139
93
140
Configuration Variables
94
141
=========================
95
142
96
- You can also add any of the following configuration values to your ``conf.py ``
143
+ Add any of the following configuration variables to your ``conf.py ``
144
+
145
+ ``linkcode_blob ``
146
+ ^^^^^^^^^^^^^^^^^^^
97
147
98
148
.. code-block :: python
99
149
100
- linkcode_blob: str = any ( ' last_tag ' , ' head' )
150
+ linkcode_blob: str = " head"
101
151
102
152
103
- The blob to link to on GitHub
153
+ The blob to link to on GitHub - any of `` "head" ``, `` "last_tag" ``, or `` "{blob}" ``
104
154
105
- * Either ``"head" ``, ``"last_tag" ``, or ``"{blob}" `` (default is ``"head" ``)
155
+ * ``head `` (default): links to the most recent commit hash; if this commit is tagged, uses the tag instead
156
+ * ``last_tag ``: links to the most recently tagged commit; if no tags exist, uses ``head ``
157
+ * ``blob ``: links to any blob you want, for example ``"master" `` or ``"v2.0.1" ``
106
158
107
- - ``head `` (default): links to the most recent commit
108
- - ``last_tag ``: links to the most recently tagged commit; if no tags exist, uses ``head ``
109
- - ``blob ``: links to any blob you want, for example ``"master" `` or ``"v2.0.1"`
110
159
160
+ ...
111
161
162
+ ``linkcode_url ``
163
+ ^^^^^^^^^^^^^^^^^^^
112
164
113
165
.. code-block :: python
114
166
115
- linkcode_url: str
167
+ linkcode_url: str = f " https://github.com/ { html_context[ ' github_user ' ] } / { html_context[ ' github_repo ' ] } / { html_context[ ' github_version ' ] } "
116
168
117
169
The link to your GitHub repository formatted as ``https://github.com/user/repo ``
118
- - If not provided, will attempt to create the link from the ``html_context `` dict
119
170
171
+ * If not provided, will attempt to create the link from the ``html_context `` dict
172
+
173
+ ...
174
+
175
+ ``linkcode_link_text ``
176
+ ^^^^^^^^^^^^^^^^^^^^^^
120
177
121
178
.. code-block :: python
122
179
123
- linkcode_link_text: str = " View on GitHub"
180
+ linkcode_link_text: str = " View on GitHub"
181
+
124
182
125
183
The text to use for the linkcode link
126
184
185
+ ...
186
+
187
+ ``linkcode_resolve ``
188
+ ^^^^^^^^^^^^^^^^^^^^^^^^
127
189
128
190
.. code-block :: python
129
191
130
192
linkcode_resolve: types.FunctionType
131
193
132
194
A ``linkcode_resolve() `` function to use for resolving the link target
133
195
134
- * Uses default :func: `~.linkcode_resolve ` if not specified (recommended)
135
-
136
-
137
- Components
138
- ~~~~~~~~~~~~~
196
+ * Uses default function from |.get_linkcode_resolve |_ if not specified (recommended)
139
197
198
+ |
140
199
141
- | .linkcode_resolve |_
142
- | .add_linkcode_node_class |_
200
+ Noteworthy Components
201
+ ~~~~~~~~~~~~~~~~~~~~~
143
202
144
- * TDKStyle - Pygments Style for syntax highlighting similar to Github Pretty Lights Dark Theme
145
- * TDKMethLexor - Pygments Lexor to add syntax highlighting to methods
146
- * |.linkcode_resolve |_ - to link to GitHub source code using ``sphinx.ext.linkcode ``
203
+ * | . TDKStyle|_ - Pygments Style for syntax highlighting similar to Github Pretty Lights Dark Theme
204
+ * | . TDKMethLexor|_ - Pygments Lexor to add syntax highlighting to methods
205
+ * |.get_linkcode_resolve |_ - to link to GitHub source code using ``sphinx.ext.linkcode ``
147
206
* |.add_linkcode_node_class |_ - adds a new ``linkcode-link `` class, allowing for CSS styling separately from ``viewcode `` links
148
- * ``github_style.css `` - CSS styling for linkcode links (icon + text)
149
-
150
-
151
- Config Values
207
+ * |.github_style |_ - CSS styling for linkcode links (icon + text)
152
208
209
+ |
153
210
154
- .. code-block :: python
155
-
156
- linkcode_blob: str = any (' last_tag' , ' head' )
157
- linkcode_link_text: str = " View on GitHub"
158
- linkcode_url: str = " https://github.com/tdkorn/sphinx-github-style"
159
- linkcode_resolve: func = None
160
-
161
-
162
- linkcode_default_blob: str = any('last_tag', 'master', 'head')
163
-
211
+ Documentation
212
+ ~~~~~~~~~~~~~~~~
164
213
214
+ Full documentation can be found on |RTD |_
0 commit comments