Skip to content

Commit 4c387bf

Browse files
committed
Update docs
1 parent e2a0de4 commit 4c387bf

File tree

11 files changed

+58
-61
lines changed

11 files changed

+58
-61
lines changed

docs/source/README.rst

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ GitHub source code links and syntax highlighting for Sphinx docs
5353
About
5454
~~~~~~~~~~~~~
5555

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

5859
...
5960

@@ -62,33 +63,42 @@ GitHub Source Code Links
6263
===============================
6364

6465

65-
Using :mod:`sphinx.ext.linkcode`, a ``View on GitHub`` link is added to the documentation of every class, method and function:
66+
Using :mod:`sphinx.ext.linkcode`, a ``View on GitHub`` link is added to the documentation of every class, method, function, and property:
6667

67-
.. image:: https://user-images.githubusercontent.com/96394652/220941352-f5530a56-d338-4b90-b83a-4b22b0f632fe.png
68-
:alt: sphinx github style adds a "View on GitHub" link
68+
.. only:: html
6969

70-
They link to and highlight the corresponding code block in your GitHub repo:
70+
.. autofunction:: sphinx_github_style.__init__.get_repo_dir
71+
:no-index:
7172

72-
.. image:: https://user-images.githubusercontent.com/96394652/220945912-447173db-2ac7-4e00-bec5-3859753bf687.png
73+
.. only:: not html
74+
75+
.. image:: https://user-images.githubusercontent.com/96394652/220941352-f5530a56-d338-4b90-b83a-4b22b0f632fe.png
76+
:alt: sphinx github style adds a "View on GitHub" link
77+
78+
79+
They link to and highlight the corresponding code block in your GitHub repository:
80+
81+
82+
.. image:: _static/github_linked_code.png
7383

7484

75-
|
7685

7786
.. note::
7887

7988
These links can be used with/instead of the links added by :mod:`sphinx.ext.viewcode`
80-
* They use a newly added ``linkcode-link`` class which can be styled using CSS
89+
* They use a newly added ``linkcode-link`` class which can be :doc:`styled using CSS <add_linkcode_class>`
8190

8291

83-
|
8492

8593
Syntax Highlighting
8694
====================
8795

88-
``sphinx-github-style`` **also contains a** ``Pygments`` **style to highlight code in your documentation similar to GitHub:**
96+
``sphinx-github-style`` **also contains a** ``Pygments`` **style to highlight code blocks similar to GitHub:**
8997

9098

91-
.. image:: https://user-images.githubusercontent.com/96394652/220946796-bf7aa236-964d-48e7-83e2-142aac00b0dd.png
99+
.. literalinclude:: ../../sphinx_github_style/__init__.py
100+
:language: python
101+
:lines: 230-246
92102

93103

94104
|
@@ -127,7 +137,6 @@ Add any (or none) of the following configuration variables to your ``conf.py``
127137
The name of the package's top-level module. For this repo, it would be ``sphinx_github_style``
128138

129139
:type: **str**
130-
:default: Return value from :func:`~.get_top_level`
131140

132141

133142
``linkcode_blob``
@@ -178,15 +187,3 @@ Add any (or none) of the following configuration variables to your ``conf.py``
178187

179188
:type: **Callable**
180189
:default: Return value from :func:`~.get_linkcode_resolve`
181-
182-
183-
|
184-
185-
Noteworthy Components
186-
~~~~~~~~~~~~~~~~~~~~~
187-
188-
* :class:`~.TDKStyle` - Pygments Style for syntax highlighting similar to Github Pretty Lights Dark Theme
189-
* :class:`~.TDKMethLexer` - Pygments Lexer to add syntax highlighting to methods
190-
* :func:`~.get_linkcode_resolve` - to link to GitHub source code using ``sphinx.ext.linkcode``
191-
* :func:`~.add_linkcode_node_class` - adds a new ``linkcode-link`` class, allowing for CSS styling separately from ``viewcode`` links
192-
* |.github_style|_ - CSS styling for linkcode links (icon + text)
87 KB
Loading

docs/source/add_linkcode_class.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
.. |.github_style| replace:: ``github_style.css``
22
.. _.github_style: https://github.com/tdkorn/sphinx-github-style/tree/v1.0.0/sphinx_github_style/_static/github_style.css
33

4-
The ``add_linkcode_class`` module
4+
CSS Styling for Linkcode Links
55
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66

7-
Add Linkcode Class for CSS Styling
8-
97
.. automodule:: sphinx_github_style.add_linkcode_class
108
:members:
119
:undoc-members:

docs/source/github_style.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
The ``github_style`` module
1+
GitHub Dark Theme Pygments Style
22
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
33

4-
:class:`~.TDKStyle` - GitHub Dark Theme Pygments Style
5-
===========================================================
6-
74
.. automodule:: sphinx_github_style.github_style
85
:members:
96
:undoc-members:

docs/source/lexer.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Pygments Lexer for Syntax Highlighting of Methods, Classes, Type Hints, and more
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
.. automodule:: sphinx_github_style.lexer
5+
:members:
6+
:undoc-members:
7+
:exclude-members: setup
8+
9+

docs/source/meth_lexer.rst

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/source/modules.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ The ``sphinx_github_style`` Package
1414

1515
add_linkcode_class
1616
github_style
17-
meth_lexer
17+
lexer

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def get_version():
2020
setup(
2121
name="sphinx-github-style",
2222
version=get_version(),
23-
description="Sphinx Github Integration and Github Dark Theme Pygments Style",
23+
description="GitHub source code links and syntax highlighting for Sphinx documentation",
2424
long_description=read(LONG_DESCRIPTION_SRC),
2525
long_description_content_type="text/x-rst; charset=UTF-8",
2626
author="Adam Korn",

sphinx_github_style/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
__author__ = 'Adam Korn <hello@dailykitten.net>'
1414

1515
from .add_linkcode_class import add_linkcode_node_class
16-
from .meth_lexer import TDKMethLexer
1716
from .github_style import TDKStyle
17+
from .lexer import TDKLexer
1818

1919

2020
def setup(app: Sphinx) -> Dict[str, Any]:
@@ -32,7 +32,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
3232
repo_dir = get_repo_dir()
3333

3434
top_level = get_conf_val(app, 'top_level')
35-
TDKMethLexer.TOP_LEVEL = top_level
35+
TDKLexer.TOP_LEVEL = top_level
3636

3737
if not callable(linkcode_func):
3838
print(
@@ -60,8 +60,8 @@ def add_static_path(app) -> None:
6060

6161

6262
def add_lexer(app: Sphinx, env) -> None:
63-
"""Registers the :class:`~.TDKMethLexer` to add GitHub dark syntax highlighting"""
64-
app.add_lexer('python', TDKMethLexer.get_pkg_lexer())
63+
"""Registers the :class:`~.TDKLexer` to add better syntax highlighting"""
64+
app.add_lexer('python', TDKLexer.get_pkg_lexer())
6565

6666

6767
def get_linkcode_revision(blob: str) -> str:
@@ -177,9 +177,9 @@ def linkcode_resolve(domain, info):
177177
modname = info['module']
178178
fullname = info['fullname']
179179

180-
if TDKMethLexer.TOP_LEVEL is None:
180+
if TDKLexer.TOP_LEVEL is None:
181181
pkg_name = modname.split('.')[0]
182-
TDKMethLexer.TOP_LEVEL = pkg_name
182+
TDKLexer.TOP_LEVEL = pkg_name
183183

184184
submod = sys.modules.get(modname)
185185
if submod is None:

sphinx_github_style/github_style.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343

4444
class TDKStyle(Style):
45-
"""An attempt at creating a Pygments style similar to GitHub's pretty lights dark theme"""
45+
"""A Pygments style similar to GitHub's pretty lights dark theme"""
4646

4747
background_color = "#0d1117"
4848
default_style = ''
@@ -123,6 +123,7 @@ class TDKStyle(Style):
123123
Punctuation: "#f8f8f2",
124124
Punctuation.Definition.Comment: pl["syntax-comment"],
125125
String: pl["syntax-string"],
126+
String.Affix: pl["syntax-string"],
126127
String.Backtick: pl["syntax-string"],
127128
String.Char: pl["syntax-string"],
128129
String.Comment: pl["syntax-comment"],

0 commit comments

Comments
 (0)