Skip to content

Commit abebfc5

Browse files
committed
feat: Impl Registry reister funcs
1 parent 4a895af commit abebfc5

4 files changed

Lines changed: 197 additions & 145 deletions

File tree

src/sphinxnotes/data/__init__.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
from . import meta
1515
from .data import (
1616
Registry,
17-
Form,
18-
BoolFlag,
19-
OperFlag,
2017
Value,
2118
ValueWrapper,
2219
RawData,
@@ -36,17 +33,16 @@
3633
BaseDataDefineDirective,
3734
StrictDataDefineDirective,
3835
)
36+
from .config import Config
3937

4038
if TYPE_CHECKING:
4139
from sphinx.application import Sphinx
4240

4341

4442
"""Python API for other Sphinx extesions."""
4543
__all__ = [
44+
'Config',
4645
'Registry',
47-
'Form',
48-
'BoolFlag',
49-
'OperFlag',
5046
'Value',
5147
'ValueWrapper',
5248
'RawData',
@@ -70,8 +66,6 @@
7066
logger = logging.getLogger(__name__)
7167

7268

73-
74-
7569
def setup(app: Sphinx):
7670
meta.pre_setup(app)
7771

src/sphinxnotes/data/config.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,25 @@
66
:license: BSD, see LICENSE for details.
77
"""
88

9+
from __future__ import annotations
910
from typing import TYPE_CHECKING
1011

1112
if TYPE_CHECKING:
1213
from sphinx.application import Sphinx
1314
from sphinx.config import Config as SphinxConfig
1415

16+
1517
class Config:
16-
"""Global config of extesion."""
18+
"""Global config of extension."""
1719

1820
template_debug: bool
1921

20-
date_fmt: str
21-
time_fmt: str
22-
datetime_fmt: str
23-
2422

25-
def _config_inited(_: Sphinx, config: SphinxConfig) -> None:
23+
def _config_inited(app: Sphinx, config: SphinxConfig) -> None:
2624
Config.template_debug = config.data_template_debug
2725

28-
Config.date_fmt = config.data_date_fmt
29-
Config.time_fmt = config.data_time_fmt
30-
Config.datetime_fmt = config.data_datetime_fmt
31-
3226

3327
def setup(app: Sphinx):
3428
app.add_config_value('data_template_debug', False, '', bool)
35-
app.add_config_value('data_date_fmt', '%Y-%m-%d', '', str)
36-
app.add_config_value('data_time_fmt', '%H:%M:%S', '', str)
37-
app.add_config_value('data_datetime_fmt', '%Y-%m-%d %H:%M:%S', '', str)
3829

3930
app.connect('config-inited', _config_inited)

0 commit comments

Comments
 (0)