File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 11"""Sphinx extension for linking code examples to reference documentation."""
22
33from pathlib import Path
4+ from shutil import copyfile
45
56from 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" )
You can’t perform that action at this time.
0 commit comments