maatlog 0.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maatlog-0.0.0/LICENSE +21 -0
- maatlog-0.0.0/PKG-INFO +146 -0
- maatlog-0.0.0/README.rst +128 -0
- maatlog-0.0.0/pyproject.toml +72 -0
- maatlog-0.0.0/pyproject.toml.orig +64 -0
- maatlog-0.0.0/src/maatlog/__init__.py +3 -0
- maatlog-0.0.0/src/maatlog/_myst_compat.py +80 -0
- maatlog-0.0.0/src/maatlog/archives.py +218 -0
- maatlog-0.0.0/src/maatlog/builders.py +72 -0
- maatlog-0.0.0/src/maatlog/clock.py +25 -0
- maatlog-0.0.0/src/maatlog/config.py +199 -0
- maatlog-0.0.0/src/maatlog/directives.py +409 -0
- maatlog-0.0.0/src/maatlog/domain.py +200 -0
- maatlog-0.0.0/src/maatlog/errors.py +81 -0
- maatlog-0.0.0/src/maatlog/extension.py +374 -0
- maatlog-0.0.0/src/maatlog/feeds.py +607 -0
- maatlog-0.0.0/src/maatlog/html_metadata.py +325 -0
- maatlog-0.0.0/src/maatlog/images.py +74 -0
- maatlog-0.0.0/src/maatlog/metadata.py +608 -0
- maatlog-0.0.0/src/maatlog/model.py +94 -0
- maatlog-0.0.0/src/maatlog/navigation.py +120 -0
- maatlog-0.0.0/src/maatlog/outputs.py +237 -0
- maatlog-0.0.0/src/maatlog/py.typed +1 -0
- maatlog-0.0.0/src/maatlog/references.py +137 -0
- maatlog-0.0.0/src/maatlog/taxonomy.py +174 -0
- maatlog-0.0.0/src/maatlog/theme_api.py +573 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-base/maatlog/archive.html +54 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-base/maatlog/components/feed-links.html +10 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-base/maatlog/components/pagination.html +18 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-base/maatlog/components/post-card.html +32 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-base/maatlog/components/sidebar.html +45 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-base/maatlog/post.html +91 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-base/maatlog-theme.toml +3 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-base/static/maatlog.css +103 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-base/theme.conf +3 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-default/maatlog-theme.toml +3 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-default/static/maatlog.css +145 -0
- maatlog-0.0.0/src/maatlog/themes/maatlog-default/theme.conf +3 -0
- maatlog-0.0.0/src/maatlog/urls.py +221 -0
- maatlog-0.0.0/src/maatlog/version.py +5 -0
- maatlog-0.0.0/src/maatlog/views.py +397 -0
maatlog-0.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 usaturn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
maatlog-0.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: maatlog
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: A Sphinx extension that turns documentation projects into static blogs.
|
|
5
|
+
Author: usaturn
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Classifier: Framework :: Sphinx :: Extension
|
|
12
|
+
Requires-Dist: sphinx>=9.1
|
|
13
|
+
Requires-Dist: myst-parser>=5.1
|
|
14
|
+
Requires-Dist: pydantic>=2
|
|
15
|
+
Requires-Python: >=3.14
|
|
16
|
+
Project-URL: Homepage, https://github.com/usaturn/maatlog
|
|
17
|
+
Description-Content-Type: text/x-rst
|
|
18
|
+
|
|
19
|
+
MaatLog
|
|
20
|
+
=======
|
|
21
|
+
|
|
22
|
+
MaatLog is a Sphinx extension that turns a documentation project into a static
|
|
23
|
+
blog. Posts are ordinary reStructuredText or MyST Markdown documents with a
|
|
24
|
+
small metadata schema. MaatLog adds archives, taxonomy navigation, Atom feeds,
|
|
25
|
+
and an HTML Theme API on top of Sphinx's public extension surface.
|
|
26
|
+
|
|
27
|
+
Requirements
|
|
28
|
+
------------
|
|
29
|
+
|
|
30
|
+
* Python 3.14+
|
|
31
|
+
* Sphinx 9.1+
|
|
32
|
+
* myst-parser 5.1+
|
|
33
|
+
|
|
34
|
+
Install
|
|
35
|
+
-------
|
|
36
|
+
|
|
37
|
+
From a built distribution (wheel or sdist)::
|
|
38
|
+
|
|
39
|
+
pip install maatlog
|
|
40
|
+
|
|
41
|
+
Or from a checkout with `uv`::
|
|
42
|
+
|
|
43
|
+
uv sync
|
|
44
|
+
uv pip install -e .
|
|
45
|
+
|
|
46
|
+
Quick start
|
|
47
|
+
-----------
|
|
48
|
+
|
|
49
|
+
1. Enable the extension and (optionally) the bundled theme in ``conf.py``::
|
|
50
|
+
|
|
51
|
+
extensions = ["maatlog"]
|
|
52
|
+
|
|
53
|
+
html_theme = "maatlog-default"
|
|
54
|
+
html_baseurl = "https://example.com/" # required when Atom feeds are enabled
|
|
55
|
+
|
|
56
|
+
maatlog_timezone = "UTC"
|
|
57
|
+
maatlog_tags = {"sphinx": "Sphinx", "python": "Python"}
|
|
58
|
+
maatlog_categories = {"engineering": "Engineering"}
|
|
59
|
+
maatlog_authors = {"alice": "Alice"}
|
|
60
|
+
|
|
61
|
+
2. Write a reStructuredText post (field list before the title)::
|
|
62
|
+
|
|
63
|
+
:maatlog-post: true
|
|
64
|
+
:maatlog-published-at: 2026-08-01T09:00:00+09:00
|
|
65
|
+
:maatlog-slug: hello-maatlog
|
|
66
|
+
:maatlog-tags: sphinx, python
|
|
67
|
+
:maatlog-categories: engineering
|
|
68
|
+
:maatlog-authors: alice
|
|
69
|
+
:maatlog-excerpt: First post with MaatLog.
|
|
70
|
+
|
|
71
|
+
Hello MaatLog
|
|
72
|
+
=============
|
|
73
|
+
|
|
74
|
+
Body of the post…
|
|
75
|
+
|
|
76
|
+
3. Or an equivalent MyST Markdown post (YAML front matter)::
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
maatlog-post: true
|
|
80
|
+
maatlog-published-at: 2026-08-01T09:00:00+09:00
|
|
81
|
+
maatlog-slug: hello-maatlog
|
|
82
|
+
maatlog-tags: [sphinx, python]
|
|
83
|
+
maatlog-categories: [engineering]
|
|
84
|
+
maatlog-authors: [alice]
|
|
85
|
+
maatlog-excerpt: First post with MaatLog.
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
# Hello MaatLog
|
|
89
|
+
|
|
90
|
+
Body of the post…
|
|
91
|
+
|
|
92
|
+
4. Build HTML::
|
|
93
|
+
|
|
94
|
+
sphinx-build -b html sourcedir builddir
|
|
95
|
+
|
|
96
|
+
With the defaults above, MaatLog generates:
|
|
97
|
+
|
|
98
|
+
* Post pages using the selected MaatLog theme
|
|
99
|
+
* Archives under ``blog/`` (configurable via ``maatlog_archive_docname``)
|
|
100
|
+
* Atom feeds under the archive root (when ``maatlog_generate_feeds`` is true)
|
|
101
|
+
* Cross-reference roles such as ``:maatlog:post:``, ``:maatlog:tag:``, and friends
|
|
102
|
+
|
|
103
|
+
Rebuild notes
|
|
104
|
+
-------------
|
|
105
|
+
|
|
106
|
+
Most ``maatlog_*`` settings rebuild the Sphinx environment (``env``). Feed-related
|
|
107
|
+
settings rebuild HTML outputs only (``html``). After changing taxonomy
|
|
108
|
+
dictionaries, archive root, page size, timezone, or feed options, run a clean
|
|
109
|
+
or full rebuild so archives and feeds stay consistent.
|
|
110
|
+
|
|
111
|
+
``SOURCE_DATE_EPOCH`` (Unix seconds, UTC) freezes the build clock used for
|
|
112
|
+
draft / scheduled / expired publication status. Prefer it for reproducible CI
|
|
113
|
+
builds.
|
|
114
|
+
|
|
115
|
+
What MaatLog does not replace
|
|
116
|
+
-----------------------------
|
|
117
|
+
|
|
118
|
+
MaatLog does not replace Sphinx document titles, toctree, search, autodoc,
|
|
119
|
+
Pygments, or intersphinx. Ordinary documentation pages coexist with posts in
|
|
120
|
+
the same project. Full HTML features (archives, Theme API validation, feeds,
|
|
121
|
+
MaatLog HTML metadata) are guaranteed for the ``html`` and ``dirhtml`` builders
|
|
122
|
+
only; other builders keep post body and role resolution where applicable.
|
|
123
|
+
|
|
124
|
+
Documentation
|
|
125
|
+
-------------
|
|
126
|
+
|
|
127
|
+
* `docs/authoring.rst` — post metadata schema and examples
|
|
128
|
+
* `docs/configuration.rst` — conf.py settings and defaults
|
|
129
|
+
* `docs/theme-api.rst` — Theme API 1.0 contract and official themes
|
|
130
|
+
* `docs/builders.rst` — builder matrix and static-site constraints
|
|
131
|
+
|
|
132
|
+
Development
|
|
133
|
+
-----------
|
|
134
|
+
|
|
135
|
+
Clone the repository, install the locked development environment, and run the
|
|
136
|
+
shared verification entrypoint::
|
|
137
|
+
|
|
138
|
+
uv sync --locked --all-groups
|
|
139
|
+
./scripts/ci/verify.sh full
|
|
140
|
+
|
|
141
|
+
License and status
|
|
142
|
+
------------------
|
|
143
|
+
|
|
144
|
+
MaatLog MVP targets Sphinx-based static blogs. Public metadata keys, config
|
|
145
|
+
names, roles, the Theme API major version, generated docname rules, and
|
|
146
|
+
diagnostic codes are compatibility-managed surfaces.
|
maatlog-0.0.0/README.rst
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
MaatLog
|
|
2
|
+
=======
|
|
3
|
+
|
|
4
|
+
MaatLog is a Sphinx extension that turns a documentation project into a static
|
|
5
|
+
blog. Posts are ordinary reStructuredText or MyST Markdown documents with a
|
|
6
|
+
small metadata schema. MaatLog adds archives, taxonomy navigation, Atom feeds,
|
|
7
|
+
and an HTML Theme API on top of Sphinx's public extension surface.
|
|
8
|
+
|
|
9
|
+
Requirements
|
|
10
|
+
------------
|
|
11
|
+
|
|
12
|
+
* Python 3.14+
|
|
13
|
+
* Sphinx 9.1+
|
|
14
|
+
* myst-parser 5.1+
|
|
15
|
+
|
|
16
|
+
Install
|
|
17
|
+
-------
|
|
18
|
+
|
|
19
|
+
From a built distribution (wheel or sdist)::
|
|
20
|
+
|
|
21
|
+
pip install maatlog
|
|
22
|
+
|
|
23
|
+
Or from a checkout with `uv`::
|
|
24
|
+
|
|
25
|
+
uv sync
|
|
26
|
+
uv pip install -e .
|
|
27
|
+
|
|
28
|
+
Quick start
|
|
29
|
+
-----------
|
|
30
|
+
|
|
31
|
+
1. Enable the extension and (optionally) the bundled theme in ``conf.py``::
|
|
32
|
+
|
|
33
|
+
extensions = ["maatlog"]
|
|
34
|
+
|
|
35
|
+
html_theme = "maatlog-default"
|
|
36
|
+
html_baseurl = "https://example.com/" # required when Atom feeds are enabled
|
|
37
|
+
|
|
38
|
+
maatlog_timezone = "UTC"
|
|
39
|
+
maatlog_tags = {"sphinx": "Sphinx", "python": "Python"}
|
|
40
|
+
maatlog_categories = {"engineering": "Engineering"}
|
|
41
|
+
maatlog_authors = {"alice": "Alice"}
|
|
42
|
+
|
|
43
|
+
2. Write a reStructuredText post (field list before the title)::
|
|
44
|
+
|
|
45
|
+
:maatlog-post: true
|
|
46
|
+
:maatlog-published-at: 2026-08-01T09:00:00+09:00
|
|
47
|
+
:maatlog-slug: hello-maatlog
|
|
48
|
+
:maatlog-tags: sphinx, python
|
|
49
|
+
:maatlog-categories: engineering
|
|
50
|
+
:maatlog-authors: alice
|
|
51
|
+
:maatlog-excerpt: First post with MaatLog.
|
|
52
|
+
|
|
53
|
+
Hello MaatLog
|
|
54
|
+
=============
|
|
55
|
+
|
|
56
|
+
Body of the post…
|
|
57
|
+
|
|
58
|
+
3. Or an equivalent MyST Markdown post (YAML front matter)::
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
maatlog-post: true
|
|
62
|
+
maatlog-published-at: 2026-08-01T09:00:00+09:00
|
|
63
|
+
maatlog-slug: hello-maatlog
|
|
64
|
+
maatlog-tags: [sphinx, python]
|
|
65
|
+
maatlog-categories: [engineering]
|
|
66
|
+
maatlog-authors: [alice]
|
|
67
|
+
maatlog-excerpt: First post with MaatLog.
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
# Hello MaatLog
|
|
71
|
+
|
|
72
|
+
Body of the post…
|
|
73
|
+
|
|
74
|
+
4. Build HTML::
|
|
75
|
+
|
|
76
|
+
sphinx-build -b html sourcedir builddir
|
|
77
|
+
|
|
78
|
+
With the defaults above, MaatLog generates:
|
|
79
|
+
|
|
80
|
+
* Post pages using the selected MaatLog theme
|
|
81
|
+
* Archives under ``blog/`` (configurable via ``maatlog_archive_docname``)
|
|
82
|
+
* Atom feeds under the archive root (when ``maatlog_generate_feeds`` is true)
|
|
83
|
+
* Cross-reference roles such as ``:maatlog:post:``, ``:maatlog:tag:``, and friends
|
|
84
|
+
|
|
85
|
+
Rebuild notes
|
|
86
|
+
-------------
|
|
87
|
+
|
|
88
|
+
Most ``maatlog_*`` settings rebuild the Sphinx environment (``env``). Feed-related
|
|
89
|
+
settings rebuild HTML outputs only (``html``). After changing taxonomy
|
|
90
|
+
dictionaries, archive root, page size, timezone, or feed options, run a clean
|
|
91
|
+
or full rebuild so archives and feeds stay consistent.
|
|
92
|
+
|
|
93
|
+
``SOURCE_DATE_EPOCH`` (Unix seconds, UTC) freezes the build clock used for
|
|
94
|
+
draft / scheduled / expired publication status. Prefer it for reproducible CI
|
|
95
|
+
builds.
|
|
96
|
+
|
|
97
|
+
What MaatLog does not replace
|
|
98
|
+
-----------------------------
|
|
99
|
+
|
|
100
|
+
MaatLog does not replace Sphinx document titles, toctree, search, autodoc,
|
|
101
|
+
Pygments, or intersphinx. Ordinary documentation pages coexist with posts in
|
|
102
|
+
the same project. Full HTML features (archives, Theme API validation, feeds,
|
|
103
|
+
MaatLog HTML metadata) are guaranteed for the ``html`` and ``dirhtml`` builders
|
|
104
|
+
only; other builders keep post body and role resolution where applicable.
|
|
105
|
+
|
|
106
|
+
Documentation
|
|
107
|
+
-------------
|
|
108
|
+
|
|
109
|
+
* `docs/authoring.rst` — post metadata schema and examples
|
|
110
|
+
* `docs/configuration.rst` — conf.py settings and defaults
|
|
111
|
+
* `docs/theme-api.rst` — Theme API 1.0 contract and official themes
|
|
112
|
+
* `docs/builders.rst` — builder matrix and static-site constraints
|
|
113
|
+
|
|
114
|
+
Development
|
|
115
|
+
-----------
|
|
116
|
+
|
|
117
|
+
Clone the repository, install the locked development environment, and run the
|
|
118
|
+
shared verification entrypoint::
|
|
119
|
+
|
|
120
|
+
uv sync --locked --all-groups
|
|
121
|
+
./scripts/ci/verify.sh full
|
|
122
|
+
|
|
123
|
+
License and status
|
|
124
|
+
------------------
|
|
125
|
+
|
|
126
|
+
MaatLog MVP targets Sphinx-based static blogs. Public metadata keys, config
|
|
127
|
+
names, roles, the Theme API major version, generated docname rules, and
|
|
128
|
+
diagnostic codes are compatibility-managed surfaces.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "maatlog"
|
|
3
|
+
version = "0.0.0"
|
|
4
|
+
description = "A Sphinx extension that turns documentation projects into static blogs."
|
|
5
|
+
readme = "README.rst"
|
|
6
|
+
requires-python = ">=3.14"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 3 - Alpha",
|
|
11
|
+
"Programming Language :: Python :: 3",
|
|
12
|
+
"Programming Language :: Python :: 3.14",
|
|
13
|
+
"Framework :: Sphinx :: Extension",
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"Sphinx>=9.1",
|
|
17
|
+
"myst-parser>=5.1",
|
|
18
|
+
"pydantic>=2",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[[project.authors]]
|
|
22
|
+
name = "usaturn"
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://github.com/usaturn/maatlog"
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["uv_build>=0.12.0,<0.13.0"]
|
|
29
|
+
build-backend = "uv_build"
|
|
30
|
+
|
|
31
|
+
[dependency-groups]
|
|
32
|
+
dev = [
|
|
33
|
+
"pytest",
|
|
34
|
+
"ruff",
|
|
35
|
+
"pyright",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
testpaths = [
|
|
40
|
+
"tests",
|
|
41
|
+
"tools/public_sync/tests",
|
|
42
|
+
]
|
|
43
|
+
pythonpath = ["tests"]
|
|
44
|
+
addopts = ["--import-mode=importlib"]
|
|
45
|
+
|
|
46
|
+
[tool.pyright]
|
|
47
|
+
pythonVersion = "3.14"
|
|
48
|
+
typeCheckingMode = "strict"
|
|
49
|
+
include = [
|
|
50
|
+
"src",
|
|
51
|
+
"tests",
|
|
52
|
+
"tools/public_sync",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[tool.ruff]
|
|
56
|
+
target-version = "py314"
|
|
57
|
+
extend-exclude = ["*.md"]
|
|
58
|
+
line-length = 119
|
|
59
|
+
|
|
60
|
+
[tool.ruff.lint]
|
|
61
|
+
select = [
|
|
62
|
+
"F",
|
|
63
|
+
"B",
|
|
64
|
+
"I",
|
|
65
|
+
"E",
|
|
66
|
+
"W",
|
|
67
|
+
]
|
|
68
|
+
ignore = []
|
|
69
|
+
fixable = ["ALL"]
|
|
70
|
+
|
|
71
|
+
[tool.ruff.format]
|
|
72
|
+
line-ending = "auto"
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "maatlog"
|
|
3
|
+
version = "0.0.0"
|
|
4
|
+
description = "A Sphinx extension that turns documentation projects into static blogs."
|
|
5
|
+
readme = "README.rst"
|
|
6
|
+
requires-python = ">=3.14"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
authors = [{ name = "usaturn" }]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Programming Language :: Python :: 3",
|
|
13
|
+
"Programming Language :: Python :: 3.14",
|
|
14
|
+
"Framework :: Sphinx :: Extension",
|
|
15
|
+
]
|
|
16
|
+
dependencies = ["Sphinx>=9.1", "myst-parser>=5.1", "pydantic>=2"]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://github.com/usaturn/maatlog"
|
|
20
|
+
|
|
21
|
+
[build-system]
|
|
22
|
+
requires = ["uv_build>=0.12.0,<0.13.0"]
|
|
23
|
+
build-backend = "uv_build"
|
|
24
|
+
|
|
25
|
+
[dependency-groups]
|
|
26
|
+
dev = ["pytest", "ruff", "pyright"]
|
|
27
|
+
|
|
28
|
+
[tool.pytest.ini_options]
|
|
29
|
+
testpaths = ["tests", "tools/public_sync/tests"]
|
|
30
|
+
pythonpath = ["tests"]
|
|
31
|
+
addopts = ["--import-mode=importlib"]
|
|
32
|
+
|
|
33
|
+
[tool.pyright]
|
|
34
|
+
pythonVersion = "3.14"
|
|
35
|
+
typeCheckingMode = "strict"
|
|
36
|
+
include = ["src", "tests", "tools/public_sync"]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
[tool.ruff]
|
|
40
|
+
target-version = "py314"
|
|
41
|
+
# ruff 既定の除外リストを保ちつつ追加する(公式は exclude ではなく extend-exclude を推奨)
|
|
42
|
+
# .venv と .ruff_cache は既定に含まれるため個別指定は不要
|
|
43
|
+
extend-exclude = [
|
|
44
|
+
"*.md", # ruff 0.16+ は Markdown 内コードブロックを整形するため除外
|
|
45
|
+
]
|
|
46
|
+
line-length = 119
|
|
47
|
+
|
|
48
|
+
[tool.ruff.lint]
|
|
49
|
+
select = [
|
|
50
|
+
"F", # Flake8
|
|
51
|
+
"B", # Black
|
|
52
|
+
"I", # isort
|
|
53
|
+
"E", # error
|
|
54
|
+
"W" # warning
|
|
55
|
+
]
|
|
56
|
+
ignore = []
|
|
57
|
+
fixable = ["ALL"]
|
|
58
|
+
|
|
59
|
+
# 自動フォーマット設定
|
|
60
|
+
[tool.ruff.format]
|
|
61
|
+
#quote-style = "double"
|
|
62
|
+
#indent-style = "space"
|
|
63
|
+
#skip-magic-trailing-comma = false
|
|
64
|
+
line-ending = "auto"
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"""Narrow compatibility adapter for typed MyST 5.1 front matter."""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Callable, Mapping
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
from typing import Protocol, cast
|
|
6
|
+
|
|
7
|
+
from myst_parser.config.main import TopmatterReadError, read_topmatter
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class _Mark(Protocol):
|
|
11
|
+
line: int
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class _ScalarNode(Protocol):
|
|
15
|
+
value: object
|
|
16
|
+
start_mark: _Mark
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class _MappingNode(Protocol):
|
|
20
|
+
value: list[tuple[_ScalarNode, object]]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class _YamlModule(Protocol):
|
|
24
|
+
compose: Callable[[str], object | None]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class _MySTRendererModule(Protocol):
|
|
28
|
+
yaml: _YamlModule
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def read_typed_frontmatter(source: str) -> dict[str, tuple[object, int]] | None:
|
|
32
|
+
"""Return MyST front matter values and one-based key lines.
|
|
33
|
+
|
|
34
|
+
``read_topmatter`` is MyST's own typed loader. MyST's renderer module owns
|
|
35
|
+
the YAML implementation used to turn the same payload into marked nodes;
|
|
36
|
+
keeping that access here prevents MaatLog from importing transitive PyYAML
|
|
37
|
+
directly and gives diagnostics the parser's key marks.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
try:
|
|
41
|
+
topmatter = read_topmatter(source)
|
|
42
|
+
except TopmatterReadError:
|
|
43
|
+
return None
|
|
44
|
+
if topmatter is None:
|
|
45
|
+
return None
|
|
46
|
+
|
|
47
|
+
payload = _frontmatter_payload(source)
|
|
48
|
+
renderer = cast(_MySTRendererModule, cast(object, import_module("myst_parser.mdit_to_docutils.base")))
|
|
49
|
+
root = renderer.yaml.compose(payload)
|
|
50
|
+
key_lines = _mapping_key_lines(root)
|
|
51
|
+
typed = cast(Mapping[object, object], topmatter)
|
|
52
|
+
return {
|
|
53
|
+
key: (value, key_lines.get(key, 1))
|
|
54
|
+
for key, value in typed.items()
|
|
55
|
+
if isinstance(key, str) and key.startswith("maatlog-")
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _frontmatter_payload(source: str) -> str:
|
|
60
|
+
lines = source.splitlines()
|
|
61
|
+
if not lines or not lines[0].startswith("---"):
|
|
62
|
+
return ""
|
|
63
|
+
payload: list[str] = []
|
|
64
|
+
for line in lines[1:]:
|
|
65
|
+
if line.startswith(("---", "...")):
|
|
66
|
+
break
|
|
67
|
+
payload.append(line)
|
|
68
|
+
return "\n".join(payload) + ("\n" if payload else "")
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _mapping_key_lines(root: object | None) -> dict[str, int]:
|
|
72
|
+
if root is None or not hasattr(root, "value"):
|
|
73
|
+
return {}
|
|
74
|
+
mapping = cast(_MappingNode, root)
|
|
75
|
+
lines: dict[str, int] = {}
|
|
76
|
+
for key_node, _ in mapping.value:
|
|
77
|
+
if isinstance(key_node.value, str):
|
|
78
|
+
# The payload begins on source line 2, while parser marks are zero-based.
|
|
79
|
+
lines[key_node.value] = key_node.start_mark.line + 2
|
|
80
|
+
return lines
|