Skip to content

Commit

Permalink
docs: Generate config docs from new schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Melkor333 committed Dec 19, 2024
1 parent 70e076a commit 0e5399d
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ __pycache__
docs/cli
docs/sphinx-template
docs/_build
docs/Command_Line_Reference.md
docs/Config_Reference.md
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test: pytest mypy lint-code ## run all testing


.PHONY: docs
docs: poetry-install
docs: poetry-install ## generate documentation
rm -vrf docs/_build/* docs/cli/*
[[ -d docs/sphinx-template ]] || git clone https://github.com/adfinis-sygroup/adsy-sphinx-template docs/sphinx-template
@docker compose exec testing bash -c "poetry install --only docs"
Expand All @@ -74,15 +74,16 @@ docs: poetry-install
@docker compose exec testing bash -c "poetry run pip install md-click==1.0.1"
@docker compose exec testing bash -c "patch -f /root/.cache/pypoetry/virtualenvs/pyaptly-*-py3.11/lib/python3.11/site-packages/md_click/main.py md-click.patch || true"

# Generate CLI docs
# Generate CLI & Config docs
@docker compose exec testing bash -c "mkdir -p docs/_temp && poetry run mdclick dumps --baseModule=pyaptly.cli --baseCommand=pyaptly --docsPath=./docs/_temp"

@docker compose exec testing bash -c "poetry run jsonschema2md pyaptly/config.schema.json docs/Config_Reference.md"

@cat docs/_temp/pyaptly.md docs/_temp/pyaptly-*.md > docs/Command_Line_Reference.md
# mdclick has not enough indentation
@sed -i 's/^#/##/' docs/Command_Line_Reference.md
# Add title, must happen after the above sed command
@sed -i '1a<!-- This file is generated with mdclick -->\n# Command Line Reference' docs/Command_Line_Reference.md
@rm -r docs/_temp
@docker compose exec testing bash -c "rm -r docs/_temp"

# SPHINX Render
@docker compose exec testing bash -c 'cd docs/ && poetry run make html'
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

README.md
Getting_Started.md
Config_Reference.md
Command_Line_Reference.md
Code_Reference.rst

Expand Down
16 changes: 15 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

195 changes: 195 additions & 0 deletions pyaptly/config.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/adfinis/pyaptly/blob/main/pyaptly/config.schema.json",
"title": "Pyaptly Configuration Schema",
"description": "The schema used for pyaptly configurations. See also https://github.com/adfinis/pyaptly/tree/main/pyaptly/tests for examples using the TOML language.",
"type": "object",
"examples": [
{
"mirror": {
"fakerepo01": {
"max-tries": 2,
"archive": "http://localhost:3123/fakerepo01",
"gpg-keys": [
"2841988729C7F3FF"
],
"components": "main",
"distribution": "main"
}
},
"snapshot": {
"fakerepo01-%T": {
"mirror": "fakerepo01",
"timestamp": {
"time": "00:00"
}
}
},
"publish": {
"fakerepo01": [
{
"gpg-key": "6D79A810B9B7ABAE",
"skip-contents": true,
"automatic-update": true,
"components": "main",
"distribution": "main",
"snapshots": [
{
"name": "fakerepo01-%T",
"timestamp": "current",
"archive-on-update": "archived-fakerepo01-%T"
}
]
}
],
"fakerepo01-stable": [
{
"publish": "fakerepo01 main",
"gpg-key": "6D79A810B9B7ABAE",
"automatic-update": true,
"components": "main",
"distribution": "main"
}
]
}
}
],
"properties": {
"mirror": {
"description": "A configuration for a mirror",
"type": "object", "additionalProperties": false,
"examples": [
{
"repo1": {
"max-tries": 2,
"archive": "http://localhost:3123/fakerepo01",
"gpg-keys": [ "2841988729C7F3FF" ],
"components": "main",
"distribution": "main"
},
"repo2": {
"archive": "http://localhost:3123/fakerepo02",
"gpg-keys": [ "2841988729C7F3FF" ],
"gpg-urls": [ "http://localhost:3123/keys/test02.key" ],
"components": "main",
"distribution": "main"
}
}
],
"patternProperties": { ".*": {
"type": "object", "additionalProperties": false,
"properties": {
"archive": { "type": "string", "description": "The URL of a remote archive to sync" },
"architectures": { "type": "array", "description": "A list of architectures. E.g. ['amd64']", "items": { "type": "string" } },
"components": { "type": ["array", "string"], "description": "A single component or list of components to download", "items": { "type": "string" } },
"distribution": { "type": "string", "description": "The Distribution of the mirror, e.g. 'squeeze'. Use './' for flat repositories." },
"gpg-keys": { "type": "array", "description": "List of GPG Key Fingerprints used to sign the packages and metadata", "items": { "type": "string" } },
"gpg-urls": { "type": "array", "description": "List of URLs to retrieve the GPG keys", "items": { "type": "string" } },
"keyserver": { "type": "string", "description": "A PGP Key Server to retrieve keys for verification" },
"max-tries": { "type": "integer", "description": "Number of tries when updating package contents" },
"sources": { "type": "boolean", "description": "If '-with-sources' should be passed to aptly" },
"udeb": { "type": "boolean", "description": "If '-with-udebs' should be passed to aptly" }
}
} }
},
"snapshot": {
"type": "object", "additionalProperties": false,
"examples": [
{
"fakerepo01-current": {
"mirror": "fakerepo01"
},
"fakerepo02-%T": {
"mirror": "fakrepo02",
"timestamp": { "time": "00:00", "repeat-weekly": "sat" }
},
"fakerepo03-%T": {
"timestamp": { "time": "00:00" },
"filter": { "query": "libhello_0.1-1_amd64",
"source": { "name": "fakerepo01-%T", "timestamp": "current" }
}
}
}
],
"patternProperties": { ".*": {
"type": "object", "additionalProperties": false,
"properties": {
"filter": { "type": "object", "additionalProperties": false, "properties": {
"query": { "type": "string" },
"source": { "type": "object", "additionalProperties": false, "properties": {
"name": { "type": "string" },
"timestamp": { "type": "string" }
} }
} },
"merge": {
"type": "array",
"items": {
"type": ["string", "object"],
"properties": {
"name": { "type": "string" },
"timestamp": { "enum": ["current", "previous", 0] }
}
}
},
"mirror": { "type": "string" },
"timestamp": { "type": "object", "additionalProperties": false, "properties": {
"time": { "type": "string" },
"repeat-weekly": { "type": "string" }
}
},
"repo": { "type": "string" }
}
} }
},
"publish": {
"type": "object", "additionalProperties": false,
"examples": [
{
"fakerepo01": [
{
"gpg-key": "6D79A810B9B7ABAE",
"skip-contents": true,
"automatic-update": true,
"components": "main",
"distribution": "main",
"snapshots": [
{
"name": "fakerepo01-%T",
"timestamp": "current",
"archive-on-update": "archived-fakerepo01-%T"
}
]
}
],
"fakerepo01-stable": [
{
"publish": "fakerepo01 main",
"gpg-key": "6D79A810B9B7ABAE",
"automatic-update": true,
"components": "main",
"distribution": "main"
}
]
}
],
"patternProperties": { ".*": {
"type": "array", "items": { "type": "object", "additionalProperties": false,
"properties": {
"architectures": { "type": "array", "description": "Which architectures should be in the publish", "items": { "type": "string" } },
"automatic-update": { "type": "boolean", "description": "If the publish should be updated when it's not explicitly mentioned as argument to pyaptly" },
"components": { "type": ["array", "string"], "description": "A single component or list of components to download", "items": { "type": "string" } },
"distribution": { "type": "string" },
"gpg-key": { "type": "string" },
"publish": { "type": "string" },
"repo": { "type": "string" },
"skip-contents": { "type": "boolean" },
"snapshots": { "type": "array", "items": { "type": ["object", "string"], "additionalProperties": false, "properties": {
"name": { "type": "string" },
"timestamp": { "type": "string" },
"archive-on-update": { "type": "string" }
} } }
} }
} }
}
}
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ sphinx = "^8.1.3"
myst-parser = "^4.0.0"
sphinx-rtd-theme = "^3.0.1"
linkify-it-py = "^2.0.3"
jsonschema2md = "^1.3.0"

[tool.coverage.run]
omit = ["pyaptly/tomli_w/_writer.py"]
Expand Down

0 comments on commit 0e5399d

Please sign in to comment.