Skip to content

Commit e0cec07

Browse files
committed
Finalize READMEs
1 parent e222368 commit e0cec07

File tree

5 files changed

+490
-75
lines changed

5 files changed

+490
-75
lines changed

README.rst

Lines changed: 107 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
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
37
.. |.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/
519

620

721
.. raw:: html
@@ -10,27 +24,27 @@
1024

1125

1226
.. 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
1428
:width: 25%
1529

1630
.. raw:: html
1731

1832
<h1>sphinx-github-style</h1>
1933

34+
GitHub source code links and syntax highlighting for Sphinx docs
2035

21-
22-
.. |RTD|_
36+
|docs|_
2337

2438
.. image:: https://img.shields.io/pypi/v/sphinx-github-style?color=eb5202
2539
:target: https://pypi.org/project/sphinx-github-style/
2640
:alt: PyPI Version
2741

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/
3044
:alt: GitHub Repository
3145

3246
.. 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/
3448

3549
.. image:: https://readthedocs.org/projects/sphinx-github-style/badge/?version=latest
3650
:target: https://sphinx-github-style.readthedocs.io/en/latest/?badge=latest
@@ -44,31 +58,62 @@
4458

4559

4660
About
47-
~~~~~~~~~
61+
~~~~~~~~~~~~~
62+
63+
``sphinx-github-style`` is a Sphinx extension that makes your docs look like and link to GitHub
64+
65+
...
4866

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+
===============================
5169

52-
Sample
53-
========
70+
.. |linkcode| replace:: ``sphinx.ext.linkcode``
71+
.. _linkcode: https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html
5472

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:**
5774

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
5976
:alt: sphinx github style adds a "View on GitHub" link
6077

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+
62104

63-
.. parse gh code
64-
.. image:: https://user-images.githubusercontent.com/96394652/220267628-10cbda6d-7f51-4e66-bdff-23410cbfacc4.png
105+
|
65106
107+
Syntax Highlighting
108+
====================
66109

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:**
68111

69-
.. parse docs code
70-
.. image:: https://user-images.githubusercontent.com/96394652/220267065-f371a152-0abe-402e-b350-d5171d933931.png
71112

113+
.. image:: https://user-images.githubusercontent.com/96394652/220946796-bf7aa236-964d-48e7-83e2-142aac00b0dd.png
114+
115+
116+
|
72117
73118
Installation
74119
~~~~~~~~~~~~~~~~
@@ -77,6 +122,7 @@ To install using ``pip``::
77122

78123
pip install sphinx-github-style
79124

125+
|
80126
81127
Configuration
82128
~~~~~~~~~~~~~~~
@@ -89,76 +135,80 @@ Add the extension to your ``conf.py``
89135
"sphinx_github_style",
90136
]
91137
138+
...
92139

93140
Configuration Variables
94141
=========================
95142

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+
^^^^^^^^^^^^^^^^^^^
97147

98148
.. code-block:: python
99149
100-
linkcode_blob: str = any('last_tag', 'head')
150+
linkcode_blob: str = "head"
101151
102152
103-
The blob to link to on GitHub
153+
The blob to link to on GitHub - any of ``"head"``, ``"last_tag"``, or ``"{blob}"``
104154

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"``
106158

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"`
110159

160+
...
111161

162+
``linkcode_url``
163+
^^^^^^^^^^^^^^^^^^^
112164

113165
.. code-block:: python
114166
115-
linkcode_url: str
167+
linkcode_url: str = f"https://github.com/{html_context['github_user']}/{html_context['github_repo']}/{html_context['github_version']}"
116168
117169
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
119170

171+
* If not provided, will attempt to create the link from the ``html_context`` dict
172+
173+
...
174+
175+
``linkcode_link_text``
176+
^^^^^^^^^^^^^^^^^^^^^^
120177

121178
.. code-block:: python
122179
123-
linkcode_link_text: str = "View on GitHub"
180+
linkcode_link_text: str = "View on GitHub"
181+
124182
125183
The text to use for the linkcode link
126184

185+
...
186+
187+
``linkcode_resolve``
188+
^^^^^^^^^^^^^^^^^^^^^^^^
127189

128190
.. code-block:: python
129191
130192
linkcode_resolve: types.FunctionType
131193
132194
A ``linkcode_resolve()`` function to use for resolving the link target
133195

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)
139197

198+
|
140199
141-
|.linkcode_resolve|_
142-
|.add_linkcode_node_class|_
200+
Noteworthy Components
201+
~~~~~~~~~~~~~~~~~~~~~
143202

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``
147206
* |.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)
152208

209+
|
153210
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+
~~~~~~~~~~~~~~~~
164213

214+
Full documentation can be found on |RTD|_

0 commit comments

Comments
 (0)