Skip to content

Commit 726d737

Browse files
committed
Make README.rst actually informative
1 parent cd2ef89 commit 726d737

File tree

1 file changed

+142
-23
lines changed

1 file changed

+142
-23
lines changed

README.rst

Lines changed: 142 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,164 @@
1-
sphinx-github-style
2-
######################
1+
.. |.linkcode_resolve| replace:: ``linkcode_resolve()``
2+
.. _.linkcode_resolve: :func:`~.linkcode_resolve`
3+
.. |.add_linkcode_node_class| replace:: ``add_linkcode_node_class()``
4+
.. _.add_linkcode_node_class: :func:`~.add_linkcode_node_class`
5+
6+
7+
.. raw:: html
8+
9+
<div align="center">
10+
11+
12+
.. image:: docs/source/_static/logo_square_grey_blue.png
13+
:alt: Sphinx GitHub Style: Magento 2 REST API wrapper
14+
:width: 25%
15+
16+
.. raw:: html
17+
18+
<h1>sphinx-github-style</h1>
19+
20+
21+
22+
.. |RTD|_
23+
24+
.. image:: https://img.shields.io/pypi/v/sphinx-github-style?color=eb5202
25+
:target: https://pypi.org/project/sphinx-github-style/
26+
:alt: PyPI Version
27+
28+
.. image:: https://img.shields.io/badge/GitHub-sphinx--github--theme-4f1abc
29+
:target: https://github.com/tdkorn/sphinx-github-style
30+
:alt: GitHub Repository
31+
32+
.. 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
34+
35+
.. image:: https://readthedocs.org/projects/sphinx-github-style/badge/?version=latest
36+
:target: https://sphinx-github-style.readthedocs.io/en/latest/?badge=latest
37+
:alt: Documentation Status
38+
39+
.. raw:: html
40+
41+
</div>
42+
<br/>
43+
<br/>
44+
45+
46+
About
47+
~~~~~~~~~
48+
49+
``sphinx-github-style`` is a
50+
Sphinx extension that adds GitHub source code links and syntax highlighting to your documentation
51+
52+
Sample
53+
========
54+
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``:
57+
58+
.. image:: https://user-images.githubusercontent.com/96394652/220267328-76b573ea-1c18-4490-9eaf-36ed9ca5a9c0.png
59+
:alt: sphinx github style adds a "View on GitHub" link
60+
61+
These link to the highlighted code in your GitHub repo:
62+
63+
.. parse gh code
64+
.. image:: https://user-images.githubusercontent.com/96394652/220267628-10cbda6d-7f51-4e66-bdff-23410cbfacc4.png
65+
66+
67+
``sphinx-github-style`` also contains a Pygments style to highlight code blocks in your documentation similar to GitHub's syntax highlighting dark theme:
68+
69+
.. parse docs code
70+
.. image:: https://user-images.githubusercontent.com/96394652/220267065-f371a152-0abe-402e-b350-d5171d933931.png
71+
72+
73+
Installation
74+
~~~~~~~~~~~~~~~~
75+
76+
To install using ``pip``::
77+
78+
pip install sphinx-github-style
79+
80+
81+
Configuration
82+
~~~~~~~~~~~~~~~
83+
84+
Add the extension to your ``conf.py``
85+
86+
.. code-block:: python
87+
88+
extensions = [
89+
"sphinx_github_style",
90+
]
91+
92+
93+
Configuration Variables
94+
=========================
95+
96+
You can also add any of the following configuration values to your ``conf.py``
97+
98+
.. code-block:: python
99+
100+
linkcode_blob: str = any('last_tag', 'head')
101+
102+
103+
The blob to link to on GitHub
104+
105+
* Either ``"head"``, ``"last_tag"``, or ``"{blob}"`` (default is ``"head"``)
106+
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+
111+
112+
113+
.. code-block:: python
114+
115+
linkcode_url: str
116+
117+
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+
120+
121+
.. code-block:: python
122+
123+
linkcode_link_text: str = "View on GitHub"
124+
125+
The text to use for the linkcode link
126+
127+
128+
.. code-block:: python
129+
130+
linkcode_resolve: types.FunctionType
131+
132+
A ``linkcode_resolve()`` function to use for resolving the link target
133+
134+
* Uses default :func:`~.linkcode_resolve` if not specified (recommended)
3135

4-
Github Pygments Style and Sphinx Integration
5136

6137
Components
7-
~~~~~~~~~~~~~~
8-
.. |.linkcode_resolve| replace:: ``~.linkcode_resolve()``
9-
.. _.linkcode_resolve: :func:`~.linkcode_resolve`
10-
.. |.add_linkcode_node_class| replace:: ``~.add_linkcode_node_class()``
11-
.. _.add_linkcode_node_class: :func:`~.add_linkcode_node_class`
138+
~~~~~~~~~~~~~
139+
12140

13141
|.linkcode_resolve|_
14142
|.add_linkcode_node_class|_
15143

16-
* TDKStyle.py - Highlights code similar to Github Pretty Lights Dark
17-
* TDKMethLexor - Highlights methods in code blocks
18-
* |.add_linkcode_node_class|_ - Updates ``linkcode`` nodes a new ``linkcode-link`` class to use for CSS styling separately from ``viewcode`` links
19-
* Add default |.linkcode_resolve|_
20-
* ``github_style``.css - Linkcode link icon + text
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``
147+
* |.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)
21149

22150

23151
Config Values
24-
~~~~~~~~~~~~~~~~~~~~~~~~~~
25152

26153

27154
.. code-block:: python
28155
29-
linkcode_default_blob: str = any('last_tag', 'master', 'head')
156+
linkcode_blob: str = any('last_tag', 'head')
30157
linkcode_link_text: str = "View on GitHub"
31158
linkcode_url: str = "https://github.com/tdkorn/sphinx-github-style"
32159
linkcode_resolve: func = None
33160
34161
35162
linkcode_default_blob: str = any('last_tag', 'master', 'head')
36163

37-
* Default is "master"
38-
* How blob is chosen
39-
- If head is a tag, uses the tag
40-
- If head is not a tag, then
41-
- If default blob is "last_tag" -> Retrieve most recent tag; if no tags exist, uses master
42-
- If default blob is "head" -> uses last commit hash; if wasn't able to get head, uses "master"
43-
- If default blob is "master" -> uses "master"
44-
45164

0 commit comments

Comments
 (0)