File tree Expand file tree Collapse file tree 3 files changed +40
-16
lines changed Expand file tree Collapse file tree 3 files changed +40
-16
lines changed Original file line number Diff line number Diff line change 152
152
# add these directories to sys.path here. If the directory is relative to the
153
153
# documentation root, use os.path.abspath to make it absolute, like shown here.
154
154
sys .path .insert (0 , os .path .abspath ('../src/sphinxnotes' ))
155
- extensions .append ('snippet.ext ' )
155
+ extensions .append ('snippet' )
156
156
157
157
# DOG FOOD CONFIGURATION START
158
158
Original file line number Diff line number Diff line change
1
+ """
2
+ sphinxnotes.snippet
3
+ ~~~~~~~~~~~~~~~~~~~
4
+
5
+ Sphinx extension entrypoint.
6
+
7
+ :copyright: Copyright 2024 Shengyu Zhang
8
+ :license: BSD, see LICENSE for details.
9
+ """
10
+
11
+
12
+ def setup (app ):
13
+ # **WARNING**: We don't import these packages globally, because the current
14
+ # package (sphinxnotes.snippet) is always resloved when importing
15
+ # sphinxnotes.snippet.*. If we import packages here, eventually we will
16
+ # load a lot of packages from the Sphinx. It will seriously **SLOW DOWN**
17
+ # the startup time of our CLI tool (sphinxnotes.snippet.cli).
18
+ #
19
+ # .. seealso:: https://github.com/sphinx-notes/snippet/pull/31
20
+ from .ext import (
21
+ SnippetBuilder ,
22
+ on_config_inited ,
23
+ on_env_get_outdated ,
24
+ on_doctree_resolved ,
25
+ on_builder_finished ,
26
+ )
27
+
28
+ app .add_builder (SnippetBuilder )
29
+
30
+ app .add_config_value ('snippet_config' , {}, '' )
31
+ app .add_config_value ('snippet_patterns' , {'*' : ['.*' ]}, '' )
32
+
33
+ app .connect ('config-inited' , on_config_inited )
34
+ app .connect ('env-get-outdated' , on_env_get_outdated )
35
+ app .connect ('doctree-resolved' , on_doctree_resolved )
36
+ app .connect ('build-finished' , on_builder_finished )
Original file line number Diff line number Diff line change 1
1
"""
2
- sphinxnotes.ext. snippet
2
+ sphinxnotes.snippet.ext
3
3
~~~~~~~~~~~~~~~~~~~~~~~
4
4
5
- Sphinx extension for sphinxnotes.snippet .
5
+ Sphinx extension implementation, but the entrypoint is located at __init__.py .
6
6
7
- :copyright: Copyright 2021 Shengyu Zhang
7
+ :copyright: Copyright 2024 Shengyu Zhang
8
8
:license: BSD, see LICENSE for details.
9
9
"""
10
10
@@ -206,15 +206,3 @@ def _format_modified_time(timestamp: float) -> str:
206
206
"""Return an RFC 3339 formatted string representing the given timestamp."""
207
207
seconds , fraction = divmod (timestamp , 1 )
208
208
return time .strftime ('%Y-%m-%d %H:%M:%S' , time .gmtime (seconds )) + f'.{ fraction :.3f} '
209
-
210
-
211
- def setup (app : Sphinx ):
212
- app .add_builder (SnippetBuilder )
213
-
214
- app .add_config_value ('snippet_config' , {}, '' )
215
- app .add_config_value ('snippet_patterns' , {'*' : ['.*' ]}, '' )
216
-
217
- app .connect ('config-inited' , on_config_inited )
218
- app .connect ('env-get-outdated' , on_env_get_outdated )
219
- app .connect ('doctree-resolved' , on_doctree_resolved )
220
- app .connect ('build-finished' , on_builder_finished )
You can’t perform that action at this time.
0 commit comments