Skip to content

Commit a2ba308

Browse files
Add mkdocs-plugins docs
1 parent 1095e28 commit a2ba308

94 files changed

Lines changed: 2715 additions & 16 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
7z a -r site.zip blacksheep
5656
5757
- name: Upload distribution package
58-
uses: actions/upload-artifact@master
58+
uses: actions/upload-artifact@v4
5959
with:
6060
name: dist
6161
path: .build/site.zip

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ venv
44
.env
55

66
# temporary
7-
mkdocs-plugins
87
rodi

blacksheep/Makefile

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@ build-v1:
1919
echo "Ready to publish"
2020

2121

22-
# require env variables
23-
publish-dev:
24-
PYAZ_ACCOUNT_KEY=${DEV_ACCOUNT_KEY} pyazblob upload --path .build/ --account-name "neoteroideveuwstacc" -cn "\$$web" -r -f
25-
26-
27-
publish-prod:
28-
PYAZ_ACCOUNT_KEY=${PROD_EUW_ACCOUNT_KEY} pyazblob upload --path .build/ --account-name "neoteroieuwstacc" -cn "\$$web" -r -f
29-
PYAZ_ACCOUNT_KEY=${PROD_USE_ACCOUNT_KEY} pyazblob upload --path .build/ --account-name "neoteroieusstacc" -cn "\$$web" -r -f
30-
31-
32-
fixlinks:
33-
./fixlinks.sh
34-
35-
3622
clean:
3723
rm -rf site/
3824
rm -rf .build/

mkdocs-plugins/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.env
2+
.build
3+
logs
4+
site
5+
6+
venv
7+
venv2

mkdocs-plugins/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# mkdocs-plugins-docs
2+
Repository containing the documentation of mkdocs-plugins.
3+
4+
* [DEV](https://neoteroideveuwstacc.z6.web.core.windows.net/mkdocs-plugins/)
5+
* [PROD](https://www.neoteroi.dev/mkdocs-plugins/)

mkdocs-plugins/debug.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"""
2+
Run this module to debug a plugin.
3+
"""
4+
from mkdocs.commands import serve
5+
6+
serve.serve(dev_addr="localhost:44555", livereload=True)

mkdocs-plugins/dev/convert.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
"""
2+
Utility to convert examples from one format to another.
3+
4+
Example:
5+
python convert.py to-yaml ../docs/timeline/timeline-1.json ../docs/timeline/timeline-1.yaml
6+
"""
7+
import json
8+
import re
9+
import sys
10+
from typing import Optional
11+
12+
import click
13+
import yaml
14+
from essentials.json import dumps as friendly_json_dumps
15+
16+
_YAML_EXT = re.compile(r"\.ya?ml$", re.IGNORECASE)
17+
_JSON_EXT = re.compile(r"\.json$", re.IGNORECASE)
18+
19+
20+
def read_text_file(file_path: str) -> str:
21+
with open(file_path, "rt", encoding="utf8") as source_file:
22+
return source_file.read()
23+
24+
25+
def write_text_file(file_path: str, contents: str):
26+
with open(file_path, "wt", encoding="utf8") as dest_file:
27+
dest_file.write(contents)
28+
29+
30+
@click.group()
31+
def convert():
32+
pass
33+
34+
35+
@click.command("to-json")
36+
@click.argument("source")
37+
@click.argument("destination", required=False)
38+
def yaml_to_json(source: str, destination: Optional[str]):
39+
if _YAML_EXT.search(source):
40+
contents = read_text_file(source)
41+
data = yaml.safe_load(contents)
42+
output = friendly_json_dumps(data, indent=4, ensure_ascii=False)
43+
if destination:
44+
write_text_file(destination, output)
45+
else:
46+
print(output)
47+
else:
48+
click.echo(f'Unsupported source: "{source}"')
49+
sys.exit(1)
50+
51+
52+
@click.command("to-yaml")
53+
@click.argument("source")
54+
@click.argument("destination", required=False)
55+
def json_to_yaml(source: str, destination: Optional[str]):
56+
if _JSON_EXT.search(source):
57+
contents = read_text_file(source)
58+
data = json.loads(contents)
59+
if destination:
60+
write_text_file(destination, yaml.dump(data))
61+
else:
62+
print(yaml.dump(data))
63+
else:
64+
click.echo(f'Unsupported source: "{source}"')
65+
sys.exit(1)
66+
67+
68+
convert.add_command(yaml_to_json)
69+
convert.add_command(json_to_yaml)
70+
71+
72+
if __name__ == "__main__":
73+
convert()

mkdocs-plugins/docs/about.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# About Neoteroi
2+
3+
[Neoteroi](https://github.com/Neoteroi/) is a collection of projects for Python.
4+
5+
## The project's home
6+
The project source code is in [GitHub](https://github.com/Neoteroi/mkdocs-plugins).
7+
8+
The documentation source code is in [GitHub](https://github.com/Neoteroi/mkdocs-plugins-docs).

0 commit comments

Comments
 (0)