Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic extra docsite document handling.
Browse files Browse the repository at this point in the history
felixfontein committed Mar 6, 2021
1 parent 1b6e559 commit 8d205de
Showing 6 changed files with 480 additions and 5 deletions.
30 changes: 30 additions & 0 deletions antsibull/cli/antsibull_lint.py
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@
from antsibull_changelog.lint import lint_changelog_yaml
from antsibull_changelog.logger import setup_logger

from antsibull.lint_docsite_docs import lint_collection_docsite_files


def run(args: List[str]) -> int:
"""
@@ -53,6 +55,16 @@ def run(args: List[str]) -> int:
metavar='/path/to/changelog.yaml',
help='path to changelogs/changelog.yaml')

collection_docs = subparsers.add_parser('collection-docs',
parents=[common],
help='Collection docs linter for inclusion in'
' docsite')
collection_docs.set_defaults(command=command_lint_collection_docs)

collection_docs.add_argument('collection_root_path',
metavar='/path/to/collection',
help='path to collection (directory that includes galaxy.yml)')

if HAS_ARGCOMPLETE:
argcomplete.autocomplete(parser)

@@ -90,6 +102,24 @@ def command_lint_changelog(args: Any) -> int:
return 3 if messages else 0


def command_lint_collection_docs(args: Any) -> int:
"""
Validate docs/docsite/rst/ in a collection.
:arg args: Parsed arguments
"""
errors = lint_collection_docsite_files(args.collection_root_path)

messages = sorted(set(
'%s:%d:%d: %s' % (error[0], error[1], error[2], error[3])
for error in errors))

for message in messages:
print(message)

return 3 if messages else 0


def main() -> int:
"""
Entrypoint called from the script.
15 changes: 13 additions & 2 deletions antsibull/cli/doc_commands/stable.py
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
from ...collections import install_together
from ...compat import asyncio_run, best_get_loop
from ...dependency_files import DepsFile
from ...docsite_docs import load_collections_docsites
from ...docs_parsing.parsing import get_ansible_plugin_info
from ...docs_parsing.fqcn import get_fqcn_parts
from ...docs_parsing.routing import (
@@ -38,6 +39,7 @@
output_collection_index,
output_indexes,
output_plugin_indexes,
output_docsites,
)

if t.TYPE_CHECKING:
@@ -327,6 +329,10 @@ def generate_docs_for_all_collections(venv: t.Union[VenvRunner, FakeVenvRunner],
flog.debug('Finished loading errors')
"""

# Load collection docsite data
docsite_data = asyncio_run(load_collections_docsites(collection_metadata))
flog.debug('Finished getting collection docsite data')

plugin_contents = get_plugin_contents(plugin_info, nonfatal_errors)
collection_to_plugin_info = get_collection_contents(plugin_contents)
# Make sure collections without documentable plugins are mentioned
@@ -344,20 +350,25 @@ def generate_docs_for_all_collections(venv: t.Union[VenvRunner, FakeVenvRunner],

asyncio_run(output_indexes(collection_to_plugin_info, dest_dir,
collection_metadata=collection_metadata,
squash_hierarchy=squash_hierarchy))
squash_hierarchy=squash_hierarchy,
docsite_data=docsite_data))
flog.notice('Finished writing indexes')

asyncio_run(output_all_plugin_stub_rst(stubs_info, dest_dir,
collection_metadata=collection_metadata,
squash_hierarchy=squash_hierarchy))
flog.debug('Finished writing plugin subs')
flog.debug('Finished writing plugin stubs')

asyncio_run(output_all_plugin_rst(collection_to_plugin_info, plugin_info,
nonfatal_errors, dest_dir,
collection_metadata=collection_metadata,
squash_hierarchy=squash_hierarchy))
flog.debug('Finished writing plugin docs')

asyncio_run(output_docsites(dest_dir, docsite_data,
squash_hierarchy=squash_hierarchy))
flog.debug('Finished writing extra docsite docs')


def generate_docs() -> int:
"""
26 changes: 26 additions & 0 deletions antsibull/data/docsite/plugins_by_collection.rst.j2
Original file line number Diff line number Diff line change
@@ -12,6 +12,32 @@ Collection version @{ collection_version }@
.. toctree::
:maxdepth: 1

{% for section in docsite_sections %}

@{section.title}@
@{ '-' * (section.title | length) }@

{% if section.toctree %}
.. toctree::
:maxdepth: 1
{% if section.entries %}
:hidden:
{% endif %}

{% for toctree_entry in section.toctree %}
@{toctree_entry}@
{% endfor %}
{% endif %}

{% for entry in section.entries %}
{% if entry.title %}
* :ref:`@{entry.title}@ <@{entry.ref}@>`
{% else %}
* :ref:`@{entry.ref}@`
{% endif %}
{% endfor %}
{% endfor %}

Plugin Index
------------

Loading

0 comments on commit 8d205de

Please sign in to comment.