Skip to content

Commit

Permalink
Remove entries.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed May 22, 2021
1 parent cbaa129 commit 616400e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 62 deletions.
15 changes: 2 additions & 13 deletions antsibull/data/docsite/plugins_by_collection.rst.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,18 @@ Collection version @{ collection_version }@
: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 %}
{% for toctree_entry in section.toctree %}
@{toctree_entry}@
{% endfor %}
{% endfor %}
{% endif %}

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

Plugin Index
Expand Down
41 changes: 3 additions & 38 deletions antsibull/docsite_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,12 @@
_RST_LABEL_DEFINITION = re.compile(r'''^\.\. _([^:]+):''')


class SectionEntry:
title: t.Optional[str]
ref: str

def __init__(self, title: t.Optional[str], ref: str):
self.title = title
self.ref = ref


class Section:
title: str
entries: t.List[SectionEntry]
toctree: t.List[str]

def __init__(self, title: str, entries: t.List[SectionEntry], toctree: t.List[str]):
def __init__(self, title: str, toctree: t.List[str]):
self.title = title
self.entries = entries
self.toctree = toctree


Expand Down Expand Up @@ -103,28 +92,6 @@ def lint_required_conditions(content: str, collection_name: str
return sorted(labels), errors


def load_entries(yaml_section: t.Dict[str, t.Any], section_index: int = 0
) -> t.Tuple[t.List[SectionEntry], t.List[str]]:
errors: t.List[str] = []
entries: t.List[SectionEntry] = []
if 'entries' in yaml_section:
for entry_index, yaml_entry in enumerate(yaml_section['entries']):
if not isinstance(yaml_entry, dict):
errors.append(f'Entry #{entry_index} in section #{section_index}'
' must be a mapping')
continue
missing = False
for required_key in ('ref', ):
if required_key not in yaml_entry:
errors.append(f'Entry #{entry_index} in section #{section_index}'
f' has no "{required_key}" entry')
missing = True
if missing:
continue
entries.append(SectionEntry(yaml_entry.get('title'), yaml_entry['ref']))
return entries, errors


def load_toctree(yaml_section: t.Dict[str, t.Any], section_index: int = 0
) -> t.Tuple[t.List[str], t.List[str]]:
errors: t.List[str] = []
Expand All @@ -151,15 +118,13 @@ def load_section(yaml_section: t.Dict[str, t.Any], section_index: int = 0
missing = True
if missing:
return None, errors
entries, entries_errors = load_entries(yaml_section, section_index)
errors.extend(entries_errors)
toctree, toctree_errors = load_toctree(yaml_section, section_index)
errors.extend(toctree_errors)
if not entries and not toctree:
if not toctree:
errors.append(
f'Section #{section_index} has no content')
return None, errors
return Section(yaml_section['title'], entries, toctree), errors
return Section(yaml_section['title'], toctree), errors


def load_docsite_index(index_path: str, report_not_existing: bool = False
Expand Down
11 changes: 0 additions & 11 deletions antsibull/lint_docsite_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

from .docsite_docs import (
find_docsite_docs,
get_label_prefix,
lint_required_conditions,
load_docsite_index,
)
Expand Down Expand Up @@ -72,14 +71,4 @@ def lint_collection_docsite_files(path_to_collection: str) -> t.List[t.Tuple[str
index_path = os.path.join(path_to_collection, 'docs', 'docsite', 'extra-docs.yml')
sections, errors = load_docsite_index(index_path, report_not_existing=len(docs) > 0)
result.extend((index_path, 0, 0, error) for error in errors)
label_prefix = get_label_prefix(collection_name)
for section in sections:
for entry in section.entries:
if not entry.ref.startswith(label_prefix):
result.append(
(index_path, 0, 0,
f'Label "{entry.ref} does not start with collection prefix "{label_prefix}"'))
elif entry.ref not in all_labels:
result.append(
(index_path, 0, 0, f'Label "{entry.ref} does not appear in included files'))
return result

0 comments on commit 616400e

Please sign in to comment.