Skip to content

Commit 40e1210

Browse files
committed
?
1 parent 2a4107c commit 40e1210

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/sphinx_codeautolink/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Sphinx extension for linking code examples to reference documentation."""
22

33
from pathlib import Path
4+
from shutil import copyfile
45

56
from sphinx.application import Sphinx
67

@@ -14,8 +15,7 @@ def setup(app: Sphinx):
1415
"""Set up extension, directives and events."""
1516
state = SphinxCodeAutoLink()
1617
app.setup_extension("sphinx.ext.autodoc")
17-
css_file = Path(__file__).parent / "static" / "sphinx-codeautolink.css"
18-
app.add_css_file(str(css_file))
18+
app.connect("build-finished", _copy_styles)
1919
app.add_config_value(
2020
"codeautolink_autodoc_inject", default=False, rebuild="html", types=[bool]
2121
)
@@ -80,3 +80,8 @@ def setup(app: Sphinx):
8080
backref.SummaryNode, html=(backref.visit_summary, backref.depart_summary)
8181
)
8282
return {"version": __version__, "env_version": 1, "parallel_read_safe": True}
83+
84+
def _copy_styles(app, exc):
85+
if app.builder.format == "html" and not exc:
86+
css_file = Path(__file__).parent / "static" / "sphinx-codeautolink.css"
87+
copyfile(css_file, app.outdir / "_static" / "sphinx-codeautolink.css")

0 commit comments

Comments
 (0)