mkdocs-data-plugin 0.1.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.
- mkdocs_data_plugin-0.1.0/.gitignore +165 -0
- mkdocs_data_plugin-0.1.0/PKG-INFO +42 -0
- mkdocs_data_plugin-0.1.0/README.md +25 -0
- mkdocs_data_plugin-0.1.0/mkdocs_data_plugin/__init__.py +2 -0
- mkdocs_data_plugin-0.1.0/mkdocs_data_plugin/plugin.py +78 -0
- mkdocs_data_plugin-0.1.0/pyproject.toml +106 -0
- mkdocs_data_plugin-0.1.0/tests/__init__.py +0 -0
- mkdocs_data_plugin-0.1.0/tests/data/a.yml +2 -0
- mkdocs_data_plugin-0.1.0/tests/data/dir1/b.yml +2 -0
- mkdocs_data_plugin-0.1.0/tests/data/dir2/c.json +4 -0
- mkdocs_data_plugin-0.1.0/tests/docs/test_data_template.md +11 -0
- mkdocs_data_plugin-0.1.0/tests/mkdocs.yml +2 -0
- mkdocs_data_plugin-0.1.0/tests/test_config.py +15 -0
- mkdocs_data_plugin-0.1.0/tests/test_data_template.py +31 -0
- mkdocs_data_plugin-0.1.0/tests/test_load_data.py +51 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Tests generated site
|
|
2
|
+
tests/site/
|
|
3
|
+
|
|
4
|
+
# Byte-compiled / optimized / DLL files
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*$py.class
|
|
8
|
+
|
|
9
|
+
# C extensions
|
|
10
|
+
*.so
|
|
11
|
+
|
|
12
|
+
# Distribution / packaging
|
|
13
|
+
.Python
|
|
14
|
+
build/
|
|
15
|
+
develop-eggs/
|
|
16
|
+
dist/
|
|
17
|
+
downloads/
|
|
18
|
+
eggs/
|
|
19
|
+
.eggs/
|
|
20
|
+
lib/
|
|
21
|
+
lib64/
|
|
22
|
+
parts/
|
|
23
|
+
sdist/
|
|
24
|
+
var/
|
|
25
|
+
wheels/
|
|
26
|
+
share/python-wheels/
|
|
27
|
+
*.egg-info/
|
|
28
|
+
.installed.cfg
|
|
29
|
+
*.egg
|
|
30
|
+
MANIFEST
|
|
31
|
+
|
|
32
|
+
# PyInstaller
|
|
33
|
+
# Usually these files are written by a python script from a template
|
|
34
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
35
|
+
*.manifest
|
|
36
|
+
*.spec
|
|
37
|
+
|
|
38
|
+
# Installer logs
|
|
39
|
+
pip-log.txt
|
|
40
|
+
pip-delete-this-directory.txt
|
|
41
|
+
|
|
42
|
+
# Unit test / coverage reports
|
|
43
|
+
htmlcov/
|
|
44
|
+
.tox/
|
|
45
|
+
.nox/
|
|
46
|
+
.coverage
|
|
47
|
+
.coverage.*
|
|
48
|
+
.cache
|
|
49
|
+
nosetests.xml
|
|
50
|
+
coverage.xml
|
|
51
|
+
*.cover
|
|
52
|
+
*.py,cover
|
|
53
|
+
.hypothesis/
|
|
54
|
+
.pytest_cache/
|
|
55
|
+
cover/
|
|
56
|
+
|
|
57
|
+
# Translations
|
|
58
|
+
*.mo
|
|
59
|
+
*.pot
|
|
60
|
+
|
|
61
|
+
# Django stuff:
|
|
62
|
+
*.log
|
|
63
|
+
local_settings.py
|
|
64
|
+
db.sqlite3
|
|
65
|
+
db.sqlite3-journal
|
|
66
|
+
|
|
67
|
+
# Flask stuff:
|
|
68
|
+
instance/
|
|
69
|
+
.webassets-cache
|
|
70
|
+
|
|
71
|
+
# Scrapy stuff:
|
|
72
|
+
.scrapy
|
|
73
|
+
|
|
74
|
+
# Sphinx documentation
|
|
75
|
+
docs/_build/
|
|
76
|
+
|
|
77
|
+
# PyBuilder
|
|
78
|
+
.pybuilder/
|
|
79
|
+
target/
|
|
80
|
+
|
|
81
|
+
# Jupyter Notebook
|
|
82
|
+
.ipynb_checkpoints
|
|
83
|
+
|
|
84
|
+
# IPython
|
|
85
|
+
profile_default/
|
|
86
|
+
ipython_config.py
|
|
87
|
+
|
|
88
|
+
# pyenv
|
|
89
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
90
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
91
|
+
# .python-version
|
|
92
|
+
|
|
93
|
+
# pipenv
|
|
94
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
95
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
96
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
97
|
+
# install all needed dependencies.
|
|
98
|
+
#Pipfile.lock
|
|
99
|
+
|
|
100
|
+
# poetry
|
|
101
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
102
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
103
|
+
# commonly ignored for libraries.
|
|
104
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
105
|
+
#poetry.lock
|
|
106
|
+
|
|
107
|
+
# pdm
|
|
108
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
109
|
+
#pdm.lock
|
|
110
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
111
|
+
# in version control.
|
|
112
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
113
|
+
.pdm.toml
|
|
114
|
+
.pdm-python
|
|
115
|
+
.pdm-build/
|
|
116
|
+
|
|
117
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
118
|
+
__pypackages__/
|
|
119
|
+
|
|
120
|
+
# Celery stuff
|
|
121
|
+
celerybeat-schedule
|
|
122
|
+
celerybeat.pid
|
|
123
|
+
|
|
124
|
+
# SageMath parsed files
|
|
125
|
+
*.sage.py
|
|
126
|
+
|
|
127
|
+
# Environments
|
|
128
|
+
.env
|
|
129
|
+
.venv
|
|
130
|
+
env/
|
|
131
|
+
venv/
|
|
132
|
+
ENV/
|
|
133
|
+
env.bak/
|
|
134
|
+
venv.bak/
|
|
135
|
+
|
|
136
|
+
# Spyder project settings
|
|
137
|
+
.spyderproject
|
|
138
|
+
.spyproject
|
|
139
|
+
|
|
140
|
+
# Rope project settings
|
|
141
|
+
.ropeproject
|
|
142
|
+
|
|
143
|
+
# mkdocs documentation
|
|
144
|
+
/site
|
|
145
|
+
|
|
146
|
+
# mypy
|
|
147
|
+
.mypy_cache/
|
|
148
|
+
.dmypy.json
|
|
149
|
+
dmypy.json
|
|
150
|
+
|
|
151
|
+
# Pyre type checker
|
|
152
|
+
.pyre/
|
|
153
|
+
|
|
154
|
+
# pytype static type analyzer
|
|
155
|
+
.pytype/
|
|
156
|
+
|
|
157
|
+
# Cython debug symbols
|
|
158
|
+
cython_debug/
|
|
159
|
+
|
|
160
|
+
# PyCharm
|
|
161
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
162
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
163
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
164
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
165
|
+
#.idea/
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: mkdocs-data-plugin
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MkDocs plugin that allows to read data from markup files
|
|
5
|
+
Project-URL: Documentation, https://joapuiib.github.io/mkdocs-data-plugin
|
|
6
|
+
Project-URL: Download, https://github.com/joapuiib/mkdocs-data-plugin/releases
|
|
7
|
+
Project-URL: Homepage, https://joapuiib.github.io/mkdocs-data-plugin
|
|
8
|
+
Project-URL: Source, https://github.com/joapuiib/mkdocs-data-plugin
|
|
9
|
+
Project-URL: Tracker, https://github.com/joapuiib/mkdocs-data-plugin/issues
|
|
10
|
+
Author-email: Joan Puigcerver <joapuiib@gmail.com>
|
|
11
|
+
License: MIT
|
|
12
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Requires-Dist: mkdocs-macros-plugin>=1.2.0
|
|
15
|
+
Requires-Dist: mkdocs>=1.5.2
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# mkdocs-data-plugin
|
|
19
|
+
MkDocs plugin that allows to read data from markup files
|
|
20
|
+
|
|
21
|
+
Currently supported formats:
|
|
22
|
+
|
|
23
|
+
- JSON
|
|
24
|
+
- YAML
|
|
25
|
+
|
|
26
|
+
## Documentation
|
|
27
|
+
This plugin documentation can be found here: https://joapuiib.github.io/mkdocs-data-plugin/
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
This plugin can be installed via pip:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install mkdocs-data-plugin
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Configuration
|
|
37
|
+
Activate the plugin in your `mkdocs.yml`:
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
plugins:
|
|
41
|
+
- data
|
|
42
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# mkdocs-data-plugin
|
|
2
|
+
MkDocs plugin that allows to read data from markup files
|
|
3
|
+
|
|
4
|
+
Currently supported formats:
|
|
5
|
+
|
|
6
|
+
- JSON
|
|
7
|
+
- YAML
|
|
8
|
+
|
|
9
|
+
## Documentation
|
|
10
|
+
This plugin documentation can be found here: https://joapuiib.github.io/mkdocs-data-plugin/
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
This plugin can be installed via pip:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install mkdocs-data-plugin
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
Activate the plugin in your `mkdocs.yml`:
|
|
21
|
+
|
|
22
|
+
```yaml
|
|
23
|
+
plugins:
|
|
24
|
+
- data
|
|
25
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import yaml
|
|
3
|
+
import json
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
from mkdocs.config.defaults import MkDocsConfig
|
|
7
|
+
from mkdocs.config import base, config_options as c
|
|
8
|
+
from mkdocs.plugins import BasePlugin, get_plugin_logger
|
|
9
|
+
|
|
10
|
+
log = get_plugin_logger(__name__)
|
|
11
|
+
|
|
12
|
+
class DataPluginConfig(base.Config):
|
|
13
|
+
data_dir = c.Type(str, default='data')
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DataPlugin(BasePlugin[DataPluginConfig]):
|
|
17
|
+
def __init__(self):
|
|
18
|
+
self.data = {}
|
|
19
|
+
self.processors = {
|
|
20
|
+
'.yml': yaml.safe_load,
|
|
21
|
+
'.yaml': yaml.safe_load,
|
|
22
|
+
'.json': json.load
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def set_data(self, keys, value):
|
|
27
|
+
"""
|
|
28
|
+
Set a value in the data attribute.
|
|
29
|
+
"""
|
|
30
|
+
data = self.data
|
|
31
|
+
for key in keys[:-1]:
|
|
32
|
+
data = data.setdefault(key, {})
|
|
33
|
+
data[keys[-1]] = value
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def on_config(self, config: MkDocsConfig):
|
|
37
|
+
self.load_data(self.config.data_dir)
|
|
38
|
+
|
|
39
|
+
macros_plugin = config.plugins.get('macros')
|
|
40
|
+
if macros_plugin:
|
|
41
|
+
macros_plugin.register_variables({'data': self.data})
|
|
42
|
+
else:
|
|
43
|
+
log.warning("The macros plugin is not installed. The `data` variable won't be available in pages.")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def load_data(self, path: str):
|
|
47
|
+
"""
|
|
48
|
+
Iterate over all files in the data directory
|
|
49
|
+
and load them into the data attribute.
|
|
50
|
+
"""
|
|
51
|
+
for root, _, files in os.walk(path):
|
|
52
|
+
|
|
53
|
+
keys = []
|
|
54
|
+
if root != self.config.data_dir:
|
|
55
|
+
directory = os.path.relpath(root, self.config.data_dir)
|
|
56
|
+
keys = directory.split(os.sep)
|
|
57
|
+
|
|
58
|
+
for file in files:
|
|
59
|
+
value = self.load_file(os.path.join(root, file))
|
|
60
|
+
|
|
61
|
+
filename, _ = os.path.splitext(file)
|
|
62
|
+
self.set_data(keys + [filename], value)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def load_file(self, path: str):
|
|
66
|
+
"""
|
|
67
|
+
Load a file and return its content.
|
|
68
|
+
"""
|
|
69
|
+
_, extension = os.path.splitext(path)
|
|
70
|
+
with open(path, 'r') as file:
|
|
71
|
+
return self.processors[extension](file)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def on_page_context(self, context, page, config, nav):
|
|
76
|
+
context['data'] = self.data
|
|
77
|
+
return context
|
|
78
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mkdocs-data-plugin"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "MkDocs plugin that allows to read data from markup files"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.8"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Joan Puigcerver", email = "joapuiib@gmail.com" },
|
|
14
|
+
]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
17
|
+
]
|
|
18
|
+
dependencies = [
|
|
19
|
+
"mkdocs>=1.5.2",
|
|
20
|
+
"mkdocs-macros-plugin>=1.2.0",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.entry-points."mkdocs.plugins"]
|
|
24
|
+
data = "mkdocs_data_plugin.plugin:DataPlugin"
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Documentation = "https://joapuiib.github.io/mkdocs-data-plugin"
|
|
28
|
+
Download = "https://github.com/joapuiib/mkdocs-data-plugin/releases"
|
|
29
|
+
Homepage = "https://joapuiib.github.io/mkdocs-data-plugin"
|
|
30
|
+
Source = "https://github.com/joapuiib/mkdocs-data-plugin"
|
|
31
|
+
Tracker = "https://github.com/joapuiib/mkdocs-data-plugin/issues"
|
|
32
|
+
|
|
33
|
+
[tool.hatch.version]
|
|
34
|
+
path = "mkdocs_data_plugin/__init__.py"
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.sdist]
|
|
37
|
+
include = [
|
|
38
|
+
"/mkdocs_data_plugin",
|
|
39
|
+
"/tests",
|
|
40
|
+
]
|
|
41
|
+
[tool.hatch.build.targets.wheel]
|
|
42
|
+
exclude = ["/tests"]
|
|
43
|
+
|
|
44
|
+
[tool.hatch.envs.default.scripts]
|
|
45
|
+
all = [
|
|
46
|
+
"hatch run test:test",
|
|
47
|
+
"hatch run style:check",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[tool.hatch.envs.test]
|
|
51
|
+
dependencies = [
|
|
52
|
+
"pytest",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[tool.hatch.envs.test.scripts]
|
|
56
|
+
test = [
|
|
57
|
+
"pytest -xs",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
[[tool.hatch.envs.test.matrix]]
|
|
61
|
+
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
|
|
62
|
+
type = ["default"]
|
|
63
|
+
|
|
64
|
+
[tool.hatch.envs.doc]
|
|
65
|
+
dependencies = [
|
|
66
|
+
"mkdocs-material>=9.2.5"
|
|
67
|
+
]
|
|
68
|
+
|
|
69
|
+
[tool.hatch.envs.doc.scripts]
|
|
70
|
+
serve = [
|
|
71
|
+
"mkdocs serve",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
[tool.hatch.envs.style]
|
|
75
|
+
detached = true
|
|
76
|
+
dependencies = [
|
|
77
|
+
"black",
|
|
78
|
+
"isort",
|
|
79
|
+
"ruff",
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
[tool.hatch.envs.style.scripts]
|
|
83
|
+
check = [
|
|
84
|
+
"isort --check-only --diff mkdocs_static_i18n",
|
|
85
|
+
"black -q --check --diff mkdocs_static_i18n",
|
|
86
|
+
"ruff check mkdocs_static_i18n",
|
|
87
|
+
]
|
|
88
|
+
format = [
|
|
89
|
+
"isort -q mkdocs_static_i18n",
|
|
90
|
+
"black -q mkdocs_static_i18n",
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
[tool.black]
|
|
94
|
+
line-length = 100
|
|
95
|
+
target-version = ["py311"]
|
|
96
|
+
skip-string-normalization = true
|
|
97
|
+
|
|
98
|
+
[tool.isort]
|
|
99
|
+
profile = "black"
|
|
100
|
+
line_length = 100
|
|
101
|
+
|
|
102
|
+
[tool.ruff]
|
|
103
|
+
line-length = 100
|
|
104
|
+
|
|
105
|
+
[tool.ruff.lint]
|
|
106
|
+
ignore = ["E501"]
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Test Data Template"
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
- data.a: `{{ data.a }}`
|
|
6
|
+
- data.a.a1: `{{ data.a.a1 }}`
|
|
7
|
+
- data.a.a2: `{{ data.a.a2 }}`
|
|
8
|
+
- data.dir1.b.b1: `{{ data.dir1.b.b1 }}`
|
|
9
|
+
- data.dir1.b.b2: `{{ data.dir1.b.b2 }}`
|
|
10
|
+
- data.dir2.c.c1: `{{ data.dir2.c.c1 }}`
|
|
11
|
+
- data.dir2.c.c2: `{{ data.dir2.c.c2 }}`
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from mkdocs.config.base import load_config
|
|
2
|
+
|
|
3
|
+
from mkdocs_data_plugin.plugin import DataPlugin
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_config_default_values():
|
|
7
|
+
plugin = DataPlugin()
|
|
8
|
+
plugin.load_config({})
|
|
9
|
+
assert plugin.config.data_dir == 'data'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_config_data_dir():
|
|
13
|
+
plugin = DataPlugin()
|
|
14
|
+
plugin.load_config({'data_dir': 'other_data'})
|
|
15
|
+
assert plugin.config.data_dir == 'other_data'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
from mkdocs.commands.build import build
|
|
4
|
+
from mkdocs.config.base import load_config
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def test_loads_files():
|
|
8
|
+
mkdocs_config = load_config(
|
|
9
|
+
"tests/mkdocs.yml",
|
|
10
|
+
plugins={
|
|
11
|
+
"macros": {},
|
|
12
|
+
"data": {'data_dir': 'tests/data'},
|
|
13
|
+
},
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
build(mkdocs_config)
|
|
17
|
+
site_dir = mkdocs_config["site_dir"]
|
|
18
|
+
|
|
19
|
+
with open(site_dir+'/test_data_template/index.html') as f:
|
|
20
|
+
data_loaded = re.findall(r"<code>([^<]*)", f.read())
|
|
21
|
+
print(data_loaded)
|
|
22
|
+
assert(data_loaded == [
|
|
23
|
+
"{'a1': 1, 'a2': 'text'}", # data/a.yml
|
|
24
|
+
"1", # data/a.yml -> a1
|
|
25
|
+
"text", # data/a.yml -> a2
|
|
26
|
+
"2", # data/dir1/b.yml -> b1
|
|
27
|
+
"text", # data/dir1/b.yml -> b2
|
|
28
|
+
"3", # data/dir2/c.yml -> c1
|
|
29
|
+
"text", # data/dir2/c.yml -> c2
|
|
30
|
+
])
|
|
31
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from mkdocs.commands.build import build
|
|
2
|
+
from mkdocs.config.base import load_config
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def test_empty_data_is_empty_dict():
|
|
6
|
+
mkdocs_config = load_config(
|
|
7
|
+
"tests/mkdocs.yml",
|
|
8
|
+
plugins={
|
|
9
|
+
"data": {'data_dir': 'tests/inexistent'}
|
|
10
|
+
},
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
build(mkdocs_config)
|
|
14
|
+
|
|
15
|
+
dataPlugin = mkdocs_config["plugins"]["data"]
|
|
16
|
+
data = dataPlugin.data
|
|
17
|
+
|
|
18
|
+
assert data == {}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_loads_files():
|
|
22
|
+
mkdocs_config = load_config(
|
|
23
|
+
"tests/mkdocs.yml",
|
|
24
|
+
plugins={
|
|
25
|
+
"data": {'data_dir': 'tests/data'}
|
|
26
|
+
},
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
build(mkdocs_config)
|
|
30
|
+
|
|
31
|
+
dataPlugin = mkdocs_config["plugins"]["data"]
|
|
32
|
+
data = dataPlugin.data
|
|
33
|
+
|
|
34
|
+
assert data == {
|
|
35
|
+
"a": {
|
|
36
|
+
"a1": 1,
|
|
37
|
+
"a2": "text",
|
|
38
|
+
},
|
|
39
|
+
"dir1": {
|
|
40
|
+
"b": {
|
|
41
|
+
"b1": 2,
|
|
42
|
+
"b2": "text",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
"dir2": {
|
|
46
|
+
"c": {
|
|
47
|
+
"c1": 3,
|
|
48
|
+
"c2": "text",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}
|