Skip to content

Commit 8f80425

Browse files
committed
refactor: __init__.py -> snippets.py
1 parent 278f624 commit 8f80425

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

src/sphinxnotes/snippet/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import List, Tuple, Dict, Optional
1010
from dataclasses import dataclass
1111

12-
from . import Snippet
12+
from .snippets import Snippet
1313
from .utils.pdict import PDict
1414

1515

src/sphinxnotes/snippet/cli.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
from textwrap import dedent
1515
from shutil import get_terminal_size
1616
import posixpath
17+
from importlib.metadata import version
1718

1819
from xdg.BaseDirectory import xdg_config_home
1920
from sphinx.util.matching import patmatch
2021

21-
from . import __version__, Document
22+
from .snippets import Document
2223
from .config import Config
2324
from .cache import Cache, IndexID, Index
2425
from .table import tablify, COLUMNS
@@ -61,7 +62,10 @@ def main(argv: List[str] = sys.argv[1:]):
6162
* (any) wildcard for any snippet"""),
6263
)
6364
parser.add_argument(
64-
'-v', '--version', action='version', version='%(prog)s ' + __version__
65+
'-v',
66+
'--version',
67+
action='version',
68+
version='%(prog)s ' + version('sphinxnotes.any'),
6569
)
6670
parser.add_argument(
6771
'-c', '--config', default=DEFAULT_CONFIG_FILE, help='path to configuration file'

src/sphinxnotes/snippet/ext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from collections.abc import Iterator
2727

2828
from .config import Config
29-
from . import Snippet, WithTitle, Document, Section
29+
from .snippets import Snippet, WithTitle, Document, Section
3030
from .picker import pick
3131
from .cache import Cache, Item
3232
from .keyword import Extractor

src/sphinxnotes/snippet/picker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from sphinx.util import logging
1717

18-
from . import Snippet, Section, Document
18+
from .snippets import Snippet, Section, Document
1919

2020
if TYPE_CHECKING:
2121
from sphinx.application import Sphinx

src/sphinxnotes/snippet/__init__.py renamed to src/sphinxnotes/snippet/snippets.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
"""
2-
sphinxnotes.snippet
3-
~~~~~~~~~~~~~~~~~~~
2+
sphinxnotes.snippet.snippets
3+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44
5-
:copyright: Copyright 2020 Shengyu Zhang
5+
Definitions of various snippets.
6+
7+
:copyright: Copyright 2024 Shengyu Zhang
68
:license: BSD, see LICENSE for details.
79
"""
810

@@ -16,14 +18,13 @@
1618
if TYPE_CHECKING:
1719
from sphinx.environment import BuildEnvironment
1820

19-
__version__ = '1.1.1'
20-
2121

2222
class Snippet(object):
2323
"""
24-
Snippet is base class of reStructuredText snippet.
24+
Snippet is structured fragments extracted from a single Sphinx document
25+
(can also be said to be a reStructuredText file).
2526
26-
:param nodes: Document nodes that make up this snippet
27+
:param nodes: nodes of doctree that make up this snippet.
2728
"""
2829

2930
#: docname where the snippet is located, can be referenced by

0 commit comments

Comments
 (0)