Skip to content

Commit 90b2593

Browse files
authored
Show 'might already be installed as part of ansible' disclaimer only on official docsite, but also for roles (#25)
* Pass for_official_docsite on to all docsite templates. * Only show 'might already be installed as part of ansible' on the official docsite. * Also show this for roles. * Add changelog fragment.
1 parent 1eeefc0 commit 90b2593

File tree

5 files changed

+76
-21
lines changed

5 files changed

+76
-21
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- "Show the 'you might already have this collection installed if you are using the ``ansible`` package' disclaimer for plugins only for official docsite builds (subcommands ``devel`` and ``stable``). Also include this disclaimer for roles on official docsite builds (https://github.com/ansible-community/antsibull-docs/pull/25)."

src/antsibull_docs/cli/doc_commands/stable.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -388,29 +388,33 @@ def generate_docs_for_all_collections(venv: t.Union[VenvRunner, FakeVenvRunner],
388388
breadcrumbs=breadcrumbs,
389389
for_official_docsite=for_official_docsite))
390390
flog.notice('Finished writing collection namespace index')
391-
asyncio_run(output_plugin_indexes(plugin_contents, dest_dir))
391+
asyncio_run(output_plugin_indexes(plugin_contents, dest_dir,
392+
for_official_docsite=for_official_docsite))
392393
flog.notice('Finished writing plugin indexes')
393394

394395
asyncio_run(output_indexes(collection_to_plugin_info, dest_dir,
395396
collection_metadata=collection_metadata,
396397
squash_hierarchy=squash_hierarchy,
397398
extra_docs_data=extra_docs_data,
398399
link_data=link_data,
399-
breadcrumbs=breadcrumbs))
400+
breadcrumbs=breadcrumbs,
401+
for_official_docsite=for_official_docsite))
400402
flog.notice('Finished writing indexes')
401403

402404
asyncio_run(output_all_plugin_stub_rst(stubs_info, dest_dir,
403405
collection_metadata=collection_metadata,
404406
link_data=link_data,
405-
squash_hierarchy=squash_hierarchy))
407+
squash_hierarchy=squash_hierarchy,
408+
for_official_docsite=for_official_docsite))
406409
flog.debug('Finished writing plugin stubs')
407410

408411
asyncio_run(output_all_plugin_rst(collection_to_plugin_info, plugin_info,
409412
nonfatal_errors, dest_dir,
410413
collection_metadata=collection_metadata,
411414
link_data=link_data,
412415
squash_hierarchy=squash_hierarchy,
413-
use_html_blobs=use_html_blobs))
416+
use_html_blobs=use_html_blobs,
417+
for_official_docsite=for_official_docsite))
414418
flog.debug('Finished writing plugin docs')
415419

416420
asyncio_run(output_extra_docs(dest_dir, extra_docs_data,

src/antsibull_docs/data/docsite/plugin.rst.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,12 @@
9292
{% else %}
9393
.. note::
9494
This {% if plugin_type == 'module' %}module{% else %}@{ plugin_type }@ plugin{% endif %} is part of the `@{collection}@ collection <https://galaxy.ansible.com/@{collection | replace('.', '/', 1)}@>`_{% if collection_version %} (version @{ collection_version }@){% endif %}.
95+
{% if for_official_docsite %}
9596

9697
You might already have this collection installed if you are using the ``ansible`` package.
9798
It is not included in ``ansible-core``.
9899
To check whether it is installed, run :code:`ansible-galaxy collection list`.
100+
{% endif %}
99101

100102
To install it, use: :code:`ansible-galaxy collection install @{collection}@`.
101103
{% if doc['requirements'] %}

src/antsibull_docs/data/docsite/role.rst.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
{% else %}
6060
.. note::
6161
This role is part of the `@{collection}@ collection <https://galaxy.ansible.com/@{collection | replace('.', '/', 1)}@>`_{% if collection_version %} (version @{ collection_version }@){% endif %}.
62+
{% if for_official_docsite %}
63+
64+
You might already have this collection installed if you are using the ``ansible`` package.
65+
It is not included in ``ansible-core``.
66+
To check whether it is installed, run :code:`ansible-galaxy collection list`.
67+
{% endif %}
6268

6369
To install it use: :code:`ansible-galaxy collection install @{collection}@`.
6470

src/antsibull_docs/write_docs.py

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def create_plugin_rst(collection_name: str,
9797
plugin_short_name: str, plugin_type: str,
9898
plugin_record: t.Dict[str, t.Any], nonfatal_errors: t.Sequence[str],
9999
plugin_tmpl: Template, error_tmpl: Template,
100-
use_html_blobs: bool = False) -> str:
100+
use_html_blobs: bool = False,
101+
for_official_docsite: bool = False) -> str:
101102
"""
102103
Create the rst page for one plugin.
103104
@@ -114,6 +115,8 @@ def create_plugin_rst(collection_name: str,
114115
:arg error_tmpl: Template to use when there wasn't enough documentation for the plugin.
115116
:arg use_html_blobs: If set to ``True``, will use HTML blobs for parameter and return value
116117
tables instead of using RST tables.
118+
:kwarg for_official_docsite: Default False. Set to True to use wording specific for the
119+
official docsite on docs.ansible.com.
117120
"""
118121
flog = mlog.fields(func='create_plugin_rst')
119122
flog.debug('Enter')
@@ -163,6 +166,7 @@ def create_plugin_rst(collection_name: str,
163166
edit_on_github_url=edit_on_github_url,
164167
collection_links=collection_links.links,
165168
collection_communication=collection_links.communication,
169+
for_official_docsite=for_official_docsite,
166170
)
167171
else:
168172
if nonfatal_errors:
@@ -185,6 +189,7 @@ def create_plugin_rst(collection_name: str,
185189
edit_on_github_url=edit_on_github_url,
186190
collection_links=collection_links.links,
187191
collection_communication=collection_links.communication,
192+
for_official_docsite=for_official_docsite,
188193
)
189194
else:
190195
plugin_contents = _render_template(
@@ -202,6 +207,7 @@ def create_plugin_rst(collection_name: str,
202207
edit_on_github_url=edit_on_github_url,
203208
collection_links=collection_links.links,
204209
collection_communication=collection_links.communication,
210+
for_official_docsite=for_official_docsite,
205211
)
206212

207213
flog.debug('Leave')
@@ -216,7 +222,8 @@ async def write_plugin_rst(collection_name: str,
216222
plugin_tmpl: Template, error_tmpl: Template, dest_dir: str,
217223
path_override: t.Optional[str] = None,
218224
squash_hierarchy: bool = False,
219-
use_html_blobs: bool = False) -> None:
225+
use_html_blobs: bool = False,
226+
for_official_docsite: bool = False) -> None:
220227
"""
221228
Write the rst page for one plugin.
222229
@@ -239,6 +246,8 @@ async def write_plugin_rst(collection_name: str,
239246
created.
240247
:arg use_html_blobs: If set to ``True``, will use HTML blobs for parameter and return value
241248
tables instead of using RST tables.
249+
:kwarg for_official_docsite: Default False. Set to True to use wording specific for the
250+
official docsite on docs.ansible.com.
242251
"""
243252
flog = mlog.fields(func='write_plugin_rst')
244253
flog.debug('Enter')
@@ -256,6 +265,7 @@ async def write_plugin_rst(collection_name: str,
256265
plugin_tmpl=plugin_tmpl,
257266
error_tmpl=error_tmpl,
258267
use_html_blobs=use_html_blobs,
268+
for_official_docsite=for_official_docsite,
259269
)
260270

261271
if path_override is not None:
@@ -284,7 +294,8 @@ async def write_stub_rst(collection_name: str, collection_meta: AnsibleCollectio
284294
tombstone_tmpl: Template,
285295
dest_dir: str,
286296
path_override: t.Optional[str] = None,
287-
squash_hierarchy: bool = False) -> None:
297+
squash_hierarchy: bool = False,
298+
for_official_docsite: bool = False) -> None:
288299
"""
289300
Write the rst page for one plugin stub.
290301
@@ -303,6 +314,8 @@ async def write_stub_rst(collection_name: str, collection_meta: AnsibleCollectio
303314
:arg squash_hierarchy: If set to ``True``, no directory hierarchy will be used.
304315
Undefined behavior if documentation for multiple collections are
305316
created.
317+
:kwarg for_official_docsite: Default False. Set to True to use wording specific for the
318+
official docsite on docs.ansible.com.
306319
"""
307320
flog = mlog.fields(func='write_stub_rst')
308321
flog.debug('Enter')
@@ -321,6 +334,7 @@ async def write_stub_rst(collection_name: str, collection_meta: AnsibleCollectio
321334
collection_links=collection_links.links,
322335
collection_communication=collection_links.communication,
323336
tombstone=routing_data['tombstone'],
337+
for_official_docsite=for_official_docsite,
324338
)
325339
else: # 'redirect' in routing_data
326340
plugin_contents = _render_template(
@@ -335,6 +349,7 @@ async def write_stub_rst(collection_name: str, collection_meta: AnsibleCollectio
335349
redirect=routing_data['redirect'],
336350
redirect_is_symlink=routing_data.get('redirect_is_symlink') or False,
337351
deprecation=routing_data.get('deprecation'),
352+
for_official_docsite=for_official_docsite,
338353
)
339354

340355
if path_override is not None:
@@ -362,7 +377,8 @@ async def output_all_plugin_rst(collection_to_plugin_info: CollectionInfoT,
362377
collection_metadata: t.Mapping[str, AnsibleCollectionMetadata],
363378
link_data: t.Mapping[str, CollectionLinks],
364379
squash_hierarchy: bool = False,
365-
use_html_blobs: bool = False) -> None:
380+
use_html_blobs: bool = False,
381+
for_official_docsite: bool = False) -> None:
366382
"""
367383
Output rst files for each plugin.
368384
@@ -379,6 +395,8 @@ async def output_all_plugin_rst(collection_to_plugin_info: CollectionInfoT,
379395
created.
380396
:arg use_html_blobs: If set to ``True``, will use HTML blobs for parameter and return value
381397
tables instead of using RST tables.
398+
:kwarg for_official_docsite: Default False. Set to True to use wording specific for the
399+
official docsite on docs.ansible.com.
382400
"""
383401
# Setup the jinja environment
384402
env = doc_environment(('antsibull_docs.data', 'docsite'))
@@ -406,7 +424,8 @@ async def output_all_plugin_rst(collection_to_plugin_info: CollectionInfoT,
406424
nonfatal_errors[plugin_type][plugin_name],
407425
plugin_type_tmpl, error_tmpl,
408426
dest_dir, squash_hierarchy=squash_hierarchy,
409-
use_html_blobs=use_html_blobs)))
427+
use_html_blobs=use_html_blobs,
428+
for_official_docsite=for_official_docsite)))
410429

411430
# Write docs for each plugin
412431
await asyncio.gather(*writers)
@@ -418,7 +437,8 @@ async def output_all_plugin_stub_rst(stubs_info: t.Mapping[
418437
collection_metadata: t.Mapping[
419438
str, AnsibleCollectionMetadata],
420439
link_data: t.Mapping[str, CollectionLinks],
421-
squash_hierarchy: bool = False) -> None:
440+
squash_hierarchy: bool = False,
441+
for_official_docsite: bool = False) -> None:
422442
"""
423443
Output rst files for each plugin stub.
424444
@@ -430,6 +450,8 @@ async def output_all_plugin_stub_rst(stubs_info: t.Mapping[
430450
:arg squash_hierarchy: If set to ``True``, no directory hierarchy will be used.
431451
Undefined behavior if documentation for multiple collections are
432452
created.
453+
:kwarg for_official_docsite: Default False. Set to True to use wording specific for the
454+
official docsite on docs.ansible.com.
433455
"""
434456
# Setup the jinja environment
435457
env = doc_environment(('antsibull_docs.data', 'docsite'))
@@ -449,7 +471,8 @@ async def output_all_plugin_stub_rst(stubs_info: t.Mapping[
449471
link_data[collection_name],
450472
plugin_short_name, plugin_type,
451473
routing_data, redirect_tmpl, tombstone_tmpl,
452-
dest_dir, squash_hierarchy=squash_hierarchy)))
474+
dest_dir, squash_hierarchy=squash_hierarchy,
475+
for_official_docsite=for_official_docsite)))
453476

454477
# Write docs for each plugin
455478
await asyncio.gather(*writers)
@@ -479,7 +502,8 @@ async def write_collection_list(collections: t.Iterable[str], namespaces: t.Iter
479502
collections=collections,
480503
namespaces=namespaces,
481504
breadcrumbs=breadcrumbs,
482-
for_official_docsite=for_official_docsite)
505+
for_official_docsite=for_official_docsite,
506+
)
483507
index_file = os.path.join(dest_dir, 'index.rst')
484508

485509
await write_file(index_file, index_contents)
@@ -509,7 +533,8 @@ async def write_collection_namespace_index(namespace: str, collections: t.Iterab
509533
namespace=namespace,
510534
collections=collections,
511535
breadcrumbs=breadcrumbs,
512-
for_official_docsite=for_official_docsite)
536+
for_official_docsite=for_official_docsite,
537+
)
513538
index_file = os.path.join(dest_dir, 'index.rst')
514539

515540
await write_file(index_file, index_contents)
@@ -518,7 +543,8 @@ async def write_collection_namespace_index(namespace: str, collections: t.Iterab
518543
async def write_plugin_type_index(plugin_type: str,
519544
per_collection_plugins: t.Mapping[str, t.Mapping[str, str]],
520545
template: Template,
521-
dest_filename: str) -> None:
546+
dest_filename: str,
547+
for_official_docsite: bool = False) -> None:
522548
"""
523549
Write an index page for each plugin type.
524550
@@ -527,12 +553,16 @@ async def write_plugin_type_index(plugin_type: str,
527553
short_description.
528554
:arg template: A template to render the plugin index.
529555
:arg dest_filename: The destination filename.
556+
:kwarg for_official_docsite: Default False. Set to True to use wording specific for the
557+
official docsite on docs.ansible.com.
530558
"""
531559
index_contents = _render_template(
532560
template,
533561
dest_filename,
534562
plugin_type=plugin_type,
535-
per_collection_plugins=per_collection_plugins)
563+
per_collection_plugins=per_collection_plugins,
564+
for_official_docsite=for_official_docsite,
565+
)
536566

537567
await write_file(dest_filename, index_contents)
538568

@@ -544,7 +574,8 @@ async def write_plugin_lists(collection_name: str,
544574
collection_meta: AnsibleCollectionMetadata,
545575
extra_docs_data: CollectionExtraDocsInfoT,
546576
link_data: CollectionLinks,
547-
breadcrumbs: bool = True) -> None:
577+
breadcrumbs: bool = True,
578+
for_official_docsite: bool = False) -> None:
548579
"""
549580
Write an index page for each collection.
550581
@@ -558,6 +589,8 @@ async def write_plugin_lists(collection_name: str,
558589
:arg link_data: Links for the collection.
559590
:kwarg breadcrumbs: Default True. Set to False if breadcrumbs for collections should be
560591
disabled. This will disable breadcrumbs but save on memory usage.
592+
:kwarg for_official_docsite: Default False. Set to True to use wording specific for the
593+
official docsite on docs.ansible.com.
561594
"""
562595
index_contents = _render_template(
563596
template,
@@ -572,6 +605,7 @@ async def write_plugin_lists(collection_name: str,
572605
collection_description=link_data.description,
573606
collection_links=link_data.links,
574607
collection_communication=link_data.communication,
608+
for_official_docsite=for_official_docsite,
575609
)
576610

577611
# This is only safe because we made sure that the top of the directory tree we're writing to
@@ -661,13 +695,16 @@ async def output_collection_namespace_indexes(collection_namespaces: t.Mapping[s
661695

662696

663697
async def output_plugin_indexes(plugin_info: PluginCollectionInfoT,
664-
dest_dir: str) -> None:
698+
dest_dir: str,
699+
for_official_docsite: bool = False) -> None:
665700
"""
666701
Generate top-level plugin index pages for all plugins of a type in all collections.
667702
668703
:arg plugin_info: Mapping of plugin_type to Mapping of collection_name to Mapping of
669704
plugin_name to short_description.
670705
:arg dest_dir: The directory to place the documentation in.
706+
:kwarg for_official_docsite: Default False. Set to True to use wording specific for the
707+
official docsite on docs.ansible.com.
671708
"""
672709
flog = mlog.fields(func='output_plugin_indexes')
673710
flog.debug('Enter')
@@ -690,7 +727,8 @@ async def output_plugin_indexes(plugin_info: PluginCollectionInfoT,
690727
filename = os.path.join(collection_toplevel, f'index_{plugin_type}.rst')
691728
writers.append(await pool.spawn(
692729
write_plugin_type_index(
693-
plugin_type, per_collection_data, plugin_list_tmpl, filename)))
730+
plugin_type, per_collection_data, plugin_list_tmpl, filename,
731+
for_official_docsite=for_official_docsite)))
694732

695733
await asyncio.gather(*writers)
696734

@@ -703,8 +741,8 @@ async def output_indexes(collection_to_plugin_info: CollectionInfoT,
703741
extra_docs_data: t.Mapping[str, CollectionExtraDocsInfoT],
704742
link_data: t.Mapping[str, CollectionLinks],
705743
squash_hierarchy: bool = False,
706-
breadcrumbs: bool = True
707-
) -> None:
744+
breadcrumbs: bool = True,
745+
for_official_docsite: bool = False) -> None:
708746
"""
709747
Generate collection-level index pages for the collections.
710748
@@ -718,6 +756,8 @@ async def output_indexes(collection_to_plugin_info: CollectionInfoT,
718756
Undefined behavior if documentation for multiple collections are created.
719757
:kwarg breadcrumbs: Default True. Set to False if breadcrumbs for collections should be
720758
disabled. This will disable breadcrumbs but save on memory usage.
759+
:kwarg for_official_docsite: Default False. Set to True to use wording specific for the
760+
official docsite on docs.ansible.com.
721761
"""
722762
flog = mlog.fields(func='output_indexes')
723763
flog.debug('Enter')
@@ -753,7 +793,8 @@ async def output_indexes(collection_to_plugin_info: CollectionInfoT,
753793
collection_dir, collection_metadata[collection_name],
754794
extra_docs_data[collection_name],
755795
link_data[collection_name],
756-
breadcrumbs=breadcrumbs)))
796+
breadcrumbs=breadcrumbs,
797+
for_official_docsite=for_official_docsite)))
757798

758799
await asyncio.gather(*writers)
759800

0 commit comments

Comments
 (0)