Skip to content

Commit 13c96bb

Browse files
committed
Declare CSS as public, document modifying style (#3)
1 parent f08b390 commit 13c96bb

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

docs/src/examples.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,28 @@ For example, a transformer could be implemented as follows:
245245
246246
Sometimes links with third-party code blocks are broken.
247247
See :ref:`about` for a potential solution.
248+
249+
Custom link styles
250+
------------------
251+
If you want a specific style to be applied to code block links,
252+
you may add your own CSS file to the Sphinx build.
253+
All code block links use the ``sphinx-codeautolink-a`` class.
254+
For example, you can add dotted lines to all links and change the hover colour:
255+
256+
.. code:: python
257+
258+
# conf.py
259+
html_static_path = ['static']
260+
html_css_files = ['custom.css']
261+
262+
.. code:: css
263+
264+
/* static/custom.css */
265+
.sphinx-codeautolink-a{
266+
border-bottom-color: rgb(0, 0, 0);
267+
border-bottom-style: dotted;
268+
border-bottom-width: 1px;
269+
}
270+
.sphinx-codeautolink-a:hover{
271+
color: rgb(255, 139, 139);
272+
}

docs/src/reference.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Reference
44
=========
5-
The public API of sphinx-codeautolink consists only of the configuration
5+
The public API of sphinx-codeautolink consists mostly of the configuration
66
and directives made available to Sphinx.
77
The extension is enabled with the name ``sphinx_codeautolink``.
88
During the build phase, a cache containing code example information is saved
@@ -106,10 +106,13 @@ Directives
106106
Skipped blocks are ignored in block concatenation as well, and concatenation
107107
is resumed without breaks after skipping is over.
108108

109+
CSS class
110+
---------
111+
The CSS class used in all code block links is ``sphinx-codeautolink-a``.
112+
109113
Cleanup function
110114
----------------
111-
An exception to the public API policy is made for a single function usable
112-
for cleaning ``pycon`` blocks.
115+
The function below is usable for cleaning ``pycon`` code blocks.
113116
It is intended to be used with :confval:`codeautolink_custom_blocks`.
114117

115118
.. autofunction:: sphinx_codeautolink.clean_pycon

docs/src/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ sphinx-codeautolink adheres to
1010

1111
Unreleased
1212
----------
13+
- Declare CSS class as public API (:issue:`3`)
1314
- Add ability to link to subclass documentation (:issue:`68`)
1415

1516
0.6.0 (2021-11-21)

0 commit comments

Comments
 (0)