Optimized docs

This commit is contained in:
2025-03-20 15:08:18 +01:00
parent 4c29fc9f02
commit 096934e795
11 changed files with 28 additions and 22 deletions

View File

@@ -20,10 +20,6 @@ generate-apidoc:
@echo "Running sphinx-apidoc..."
sphinx-apidoc -f -o $(SPHINX_GENERATED_DIR)/modules $(SPHINX_SOURCE_DIR)
remove-generated:
@echo "Removing generated files..."
- find $(SPHINX_GENERATED_DIR)/ -type f ! -name '.gitkeep' -delete
generate-yaml-index:
@echo "Generating YAML index..."
python generators/yaml_index.py --source-dir $(SPHINX_SOURCE_DIR) --output-file $(SPHINX_GENERATED_DIR)/yaml_index.rst
@@ -32,16 +28,23 @@ generate-ansible-roles:
@echo "Generating Ansible roles documentation..."
python generators/ansible_roles.py --roles-dir $(SPHINX_SOURCE_DIR)/roles --output-dir $(SPHINX_GENERATED_DIR)/roles
remove-generated:
@echo "Removing generated files..."
- find $(SPHINX_GENERATED_DIR)/ -type f ! -name '.gitkeep' -delete
# "help" target does not copy images
help:
@$(SPHINXBUILD) -M help "$(SPHINX_SOURCE_DIR)" "$(SPHINX_BUILD_DIR)" $(SPHINXOPTS) $(O)
html: copy-images generate-apidoc generate-yaml-index generate-ansible-roles
html: copy-images generate-apidoc generate-ansible-roles generate-yaml-index
@$(SPHINXBUILD) -M html "$(SPHINX_SOURCE_DIR)" "$(SPHINX_BUILD_DIR)" $(SPHINXOPTS)
just-html:
@$(SPHINXBUILD) -M html "$(SPHINX_SOURCE_DIR)" "$(SPHINX_BUILD_DIR)" $(SPHINXOPTS)
clean: remove-generated
@$(SPHINXBUILD) -M html "$(SPHINX_SOURCE_DIR)" "$(SPHINX_BUILD_DIR)" $(SPHINXOPTS) $(O)
@$(SPHINXBUILD) -M clean "$(SPHINX_SOURCE_DIR)" "$(SPHINX_BUILD_DIR)" $(SPHINXOPTS) $(O)
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).

View File

@@ -52,16 +52,16 @@ html_theme_options = {
}
source_suffix = {
'.rst': 'restructuredtext',
'.md': 'markdown',
'.rst': 'restructuredtext',
'.yml': 'restructuredtext',
'.yaml': 'restructuredtext',
}
sys.path.insert(0, os.path.abspath('./extensions'))
extensions = [
'sphinx.ext.autosummary',
'sphinx.ext.autodoc',
#'sphinx.ext.autosummary',
'myst_parser',
'extensions.local_file_headings',
'extensions.local_subfolders',

View File

@@ -36,7 +36,9 @@ def generate_yaml_index(source_dir, output_file):
f.write("This document lists all `.yaml` and `.yml` files found in the specified directory, excluding ignored files.\n\n")
for file in sorted(yaml_files):
f.write(f".. literalinclude:: {file}\n :language: yaml\n :linenos:\n\n")
relative_file_path = os.path.relpath(file, start=os.path.dirname(output_file))
f.write(f".. literalinclude:: {relative_file_path}\n :language: yaml\n :linenos:\n\n")
print(f"YAML index has been generated at {output_file}")