Skip to content

Commit

Permalink
Avoid extra information.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed May 24, 2021
1 parent b927800 commit 4f22297
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
3 changes: 2 additions & 1 deletion antsibull/cli/doc_commands/stable.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ def generate_docs_for_all_collections(venv: t.Union[VenvRunner, FakeVenvRunner],
"""

# Load collection extra docs data
extra_docs_data = asyncio_run(load_collections_extra_docs(collection_metadata))
extra_docs_data = asyncio_run(load_collections_extra_docs(
{name: data.path for name, data in collection_metadata.items()}))
flog.debug('Finished getting collection extra docs data')

plugin_contents = get_plugin_contents(plugin_info, nonfatal_errors)
Expand Down
18 changes: 8 additions & 10 deletions antsibull/extra_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import asyncio_pool

from . import app_context
from .docs_parsing import AnsibleCollectionMetadata
from .logging import log
from .yaml import load_yaml_file

Expand Down Expand Up @@ -162,21 +161,21 @@ def load_extra_docs_index(index_path: str) -> t.Tuple[t.List[Section], t.List[st


async def load_collection_extra_docs(collection_name: str,
collection_metadata: AnsibleCollectionMetadata,
collection_path: str,
path_prefix: str = 'docsite'
) -> CollectionExtraDocsInfoT:
'''Given a collection name and collection metadata, load extra docs data.
:arg collection_name: Dotted collection name.
:arg collection_metadata: Collection metadata object.
:arg collection_path: Path to the collection.
:arg path_prefix: Prefix to add to relative paths, and toctree entries.
:returns: A tuple consisting of a list of sections and a list of RST documents as tuples
(relative path in docs/docsite/rst, content).
'''
flog = mlog.fields(func='load_collection_extra_docs')
flog.debug('Enter')

index_path = os.path.join(collection_metadata.path, 'docs', 'docsite', 'extra-docs.yml')
index_path = os.path.join(collection_path, 'docs', 'docsite', 'extra-docs.yml')
try:
sections, dummy = load_extra_docs_index(index_path)
except ExtraDocsIndexError:
Expand All @@ -186,7 +185,7 @@ async def load_collection_extra_docs(collection_name: str,
for i, toctree in enumerate(section.toctree):
section.toctree[i] = f"{path_prefix}/{toctree}"
documents = []
for abs_path, rel_path in find_extra_docs(collection_metadata.path):
for abs_path, rel_path in find_extra_docs(collection_path):
try:
# Load content
async with aiofiles.open(abs_path, 'r', encoding='utf-8') as f:
Expand All @@ -205,12 +204,11 @@ async def load_collection_extra_docs(collection_name: str,
return sections, documents


async def load_collections_extra_docs(collection_metadata: t.Mapping[
str, AnsibleCollectionMetadata]
async def load_collections_extra_docs(collection_paths: t.Mapping[str, str]
) -> t.Mapping[str, CollectionExtraDocsInfoT]:
'''Load extra docs data.
:arg collection_metadata: Mapping of collection_name to AnsibleCollectionMetadata.
:arg collection_paths: Mapping of collection_name to the collection's path.
:returns: A mapping of collection_name to CollectionExtraDocsInfoT.
'''
flog = mlog.fields(func='load_collections_extra_docs')
Expand All @@ -220,9 +218,9 @@ async def load_collections_extra_docs(collection_metadata: t.Mapping[
lib_ctx = app_context.lib_ctx.get()

async with asyncio_pool.AioPool(size=lib_ctx.thread_max) as pool:
for collection_name, metadata in collection_metadata.items():
for collection_name, collection_path in collection_paths.items():
loaders[collection_name] = await pool.spawn(
load_collection_extra_docs(collection_name, metadata))
load_collection_extra_docs(collection_name, collection_path))

responses = await asyncio.gather(*loaders.values())

Expand Down

0 comments on commit 4f22297

Please sign in to comment.