Skip to content

Commit b67d559

Browse files
Documentation: Store doc builds in repo (#427)
1 parent 1aa0e16 commit b67d559

File tree

81 files changed

+2083
-739
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2083
-739
lines changed

.readthedocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: 2
2-
sphinx:
3-
configuration: docs/conf.py
2+
#sphinx:
3+
# configuration: docs/conf.py
44

55
python:
66
version: 3.6

docs/changelog/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
=====================
2+
CHANGELOG
3+
=====================
14

25
.. toctree::
36
:maxdepth: 4

docs/conf.py

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import re
1616
import stat
1717
from pathlib import Path
18-
from antsibull.cli.antsibull_docs import run
18+
from antsibull.cli import antsibull_docs
1919

2020
sys.path.insert(0, os.path.abspath("../"))
2121

@@ -27,7 +27,7 @@
2727
author = "Mikhail Yohman <@FragmentedPacket>"
2828

2929
# The full version, including alpha/beta/rc tags
30-
release = "1.1.0"
30+
release = "2.0.0"
3131

3232

3333
# -- General configuration ---------------------------------------------------
@@ -84,18 +84,25 @@ def create_antsibull_docs(files, plugin_type=None):
8484
"""
8585
for f in files:
8686
file_name = re.search(r"(?:.+\/)(\S+)\.py", str(f)).group(1)
87-
if file_name == "netbox_interface":
87+
if file_name in ["netbox_interface"]:
8888
continue
8989

90+
print(file_name)
9091
if plugin_type is not None:
91-
args_string = f"junk plugin --dest-dir plugins/{plugin_type}/{file_name}/ --plugin-type {plugin_type} netbox.netbox.{file_name}"
92+
file_path = Path(f"plugins/{plugin_type}/{file_name}/")
9293
else:
93-
args_string = f"junk plugin --dest-dir plugins/modules/{file_name}/ --plugin-type module netbox.netbox.{file_name}"
94+
file_path = Path(f"plugins/modules/{file_name}/")
95+
96+
file_path.mkdir(mode=744, exist_ok=True)
97+
98+
if plugin_type is not None:
99+
args_string = f"junk plugin --dest-dir {file_path} --plugin-type {plugin_type} netbox.netbox.{file_name}"
100+
else:
101+
args_string = f"junk plugin --dest-dir {file_path} --plugin-type module netbox.netbox.{file_name}"
94102
args = args_string.split(" ")
95103
try:
96-
run(args)
97-
except:
98-
print(args)
104+
antsibull_docs.run(args)
105+
except Exception as e:
99106
sys.exit(1)
100107

101108

@@ -113,30 +120,32 @@ def build_ansible_docs(app):
113120
"""
114121
This will perform all necessary actions to use antsibull-docs to generate collection docs
115122
"""
116-
if os.environ.get("READTHEDOCS") != "True":
117-
inventory_path = Path("../plugins/inventory/")
118-
lookup_path = Path("../plugins/lookup/")
119-
modules_path = Path("../plugins/modules/")
123+
inventory_path = Path("../plugins/inventory/")
124+
lookup_path = Path("../plugins/lookup/")
125+
modules_path = Path("../plugins/modules/")
120126

121-
# Set permissions on folders within docs/plugins to remove w from g+o
122-
doc_modules = Path("plugins/modules/")
123-
doc_lookup = Path("plugins/lookup/")
124-
doc_inventory = Path("plugins/inventory/")
125-
remove_write_permissions(doc_modules)
126-
remove_write_permissions(doc_lookup)
127-
remove_write_permissions(doc_inventory)
127+
# Set permissions on folders within docs/plugins to remove w from g+o
128+
doc_modules = Path("plugins/modules/")
129+
doc_lookup = Path("plugins/lookup/")
130+
doc_inventory = Path("plugins/inventory/")
131+
remove_write_permissions(doc_modules)
132+
remove_write_permissions(doc_lookup)
133+
remove_write_permissions(doc_inventory)
128134

129-
inventory = inventory_path.glob("[!_]*.py")
130-
lookup = lookup_path.glob("[!_]*.py")
131-
modules = modules_path.glob("[!_]*.py")
135+
inventory = inventory_path.glob("[!_]*.py")
136+
lookup = lookup_path.glob("[!_]*.py")
137+
modules = modules_path.glob("[!_]*.py")
132138

133-
create_antsibull_docs(inventory, "inventory")
134-
create_antsibull_docs(lookup, "lookup")
135-
create_antsibull_docs(modules)
139+
create_antsibull_docs(inventory, "inventory")
140+
create_antsibull_docs(lookup, "lookup")
141+
create_antsibull_docs(modules)
136142

137143

138-
def setup(app):
139-
app.connect("builder-inited", build_ansible_docs)
144+
###########################################
145+
# NOT IN USE AND SHOULD BE MANUALLY BUILT
146+
################
147+
# def setup(app):
148+
# app.connect("builder-inited", build_ansible_docs)
140149

141150

142-
build_ansible_docs(None)
151+
# build_ansible_docs(None)

docs/getting_started/contributing/modules/new_module.rst

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,38 @@ Next we'll create a new file named ``tests/integration/targets/latest/netbox_rou
424424
I won't be posting the actual implementation of this as it is a few hundred lines long, but you can view it by browsing to the specific file. To run the integration tests, it is best to push your changes up
425425
and let CI/CD pipeline to run, but we will be updating the development to allow local testing.
426426
427-
After all tests pass, open a PR and wait for feedback or for the PR to be merged in.
427+
After all tests pass, let's generate our new documents. From the root of the collection, run the following commands.
428428
429-
This new model within NetBox is also tied to VRFs as ``import_targets`` and ``export_targets``. Here is a screenshot of the new options we will need to add to the :ref:`netbox_vrf module<ansible_collections.netbox.netbox.netbox_vrf>`.
429+
.. code-block:: bash
430+
431+
❯ poetry shell && poetry install
432+
❯ ./hacking/make-docs.sh
433+
rm: tests/output: No such file or directory
434+
rm: .pytest_cache: No such file or directory
435+
Using /Users/myohman/cloned-repos/ansible_modules/ansible.cfg as config file
436+
Created collection for netbox.netbox at /Users/myohman/cloned-repos/ansible_modules/netbox-netbox-2.0.0.tar.gz
437+
Starting galaxy collection install process
438+
[WARNING]: The specified collections path '/Users/myohman/cloned-repos/ansible_modules' is not part of the configured Ansible collections paths
439+
'/Users/myohman/.ansible/collections:/usr/share/ansible/collections'. The installed collection won't be picked up in an Ansible run.
440+
Process install dependency map
441+
Starting collection install process
442+
Installing 'netbox.netbox:2.0.0' to '/Users/myohman/cloned-repos/ansible_modules/ansible_collections/netbox/netbox'
443+
netbox.netbox (2.0.0) was installed successfully
444+
Installing 'ansible.netcommon:1.4.1' to '/Users/myohman/cloned-repos/ansible_modules/ansible_collections/ansible/netcommon'
445+
Downloading https://galaxy.ansible.com/download/ansible-netcommon-1.4.1.tar.gz to /Users/myohman/.ansible/tmp/ansible-local-4390k59zwzli/tmp5871aum5
446+
ansible.netcommon (1.4.1) was installed successfully
447+
Installing 'community.general:1.3.4' to '/Users/myohman/cloned-repos/ansible_modules/ansible_collections/community/general'
448+
Downloading https://galaxy.ansible.com/download/community-general-1.3.4.tar.gz to /Users/myohman/.ansible/tmp/ansible-local-4390k59zwzli/tmp5871aum5
449+
community.general (1.3.4) was installed successfully
450+
Installing 'google.cloud:1.0.1' to '/Users/myohman/cloned-repos/ansible_modules/ansible_collections/google/cloud'
451+
Downloading https://galaxy.ansible.com/download/google-cloud-1.0.1.tar.gz to /Users/myohman/.ansible/tmp/ansible-local-4390k59zwzli/tmp5871aum5
452+
google.cloud (1.0.1) was installed successfully
453+
Installing 'community.kubernetes:1.1.1' to '/Users/myohman/cloned-repos/ansible_modules/ansible_collections/community/kubernetes'
454+
Downloading https://galaxy.ansible.com/download/community-kubernetes-1.1.1.tar.gz to /Users/myohman/.ansible/tmp/ansible-local-4390k59zwzli/tmp5871aum5
455+
community.kubernetes (1.1.1) was installed successfully
456+
ERROR:antsibull:error=Cannot find plugin:func=get_ansible_plugin_info:mod=antsibull.docs_parsing.ansible_internal:plugin_name=netbox.netbox.netbox_interface:plugin_type=module|Error while extracting documentation. Will not document this plugin.
457+
458+
Let's move onto updating ``netbox_vrf`` module. This new model within NetBox is also tied to VRFs as ``import_targets`` and ``export_targets``. Here is a screenshot of the new options we will need to add to the :ref:`netbox_vrf module<ansible_collections.netbox.netbox.netbox_vrf>`.
430459
431460
.. image:: ./media/vrf_options.png
432461

docs/getting_started/contributing/modules/update_module.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,35 @@ Next we'll update ``netbox_vrf.yml`` for the **latest** integration target.
193193
194194
We added the **import_targets** and **export_targets** when updating the VRF and then asserting that the length of both the **after** and **vrf** object are both one.
195195
196+
Let's generate our new documents. From the root of the collection, run the following commands.
197+
198+
.. code-block:: bash
199+
200+
❯ poetry shell && poetry install
201+
❯ ./hacking/make-docs.sh
202+
rm: tests/output: No such file or directory
203+
rm: .pytest_cache: No such file or directory
204+
Using /Users/myohman/cloned-repos/ansible_modules/ansible.cfg as config file
205+
Created collection for netbox.netbox at /Users/myohman/cloned-repos/ansible_modules/netbox-netbox-2.0.0.tar.gz
206+
Starting galaxy collection install process
207+
[WARNING]: The specified collections path '/Users/myohman/cloned-repos/ansible_modules' is not part of the configured Ansible collections paths
208+
'/Users/myohman/.ansible/collections:/usr/share/ansible/collections'. The installed collection won't be picked up in an Ansible run.
209+
Process install dependency map
210+
Starting collection install process
211+
Installing 'netbox.netbox:2.0.0' to '/Users/myohman/cloned-repos/ansible_modules/ansible_collections/netbox/netbox'
212+
netbox.netbox (2.0.0) was installed successfully
213+
Installing 'ansible.netcommon:1.4.1' to '/Users/myohman/cloned-repos/ansible_modules/ansible_collections/ansible/netcommon'
214+
Downloading https://galaxy.ansible.com/download/ansible-netcommon-1.4.1.tar.gz to /Users/myohman/.ansible/tmp/ansible-local-4390k59zwzli/tmp5871aum5
215+
ansible.netcommon (1.4.1) was installed successfully
216+
Installing 'community.general:1.3.4' to '/Users/myohman/cloned-repos/ansible_modules/ansible_collections/community/general'
217+
Downloading https://galaxy.ansible.com/download/community-general-1.3.4.tar.gz to /Users/myohman/.ansible/tmp/ansible-local-4390k59zwzli/tmp5871aum5
218+
community.general (1.3.4) was installed successfully
219+
Installing 'google.cloud:1.0.1' to '/Users/myohman/cloned-repos/ansible_modules/ansible_collections/google/cloud'
220+
Downloading https://galaxy.ansible.com/download/google-cloud-1.0.1.tar.gz to /Users/myohman/.ansible/tmp/ansible-local-4390k59zwzli/tmp5871aum5
221+
google.cloud (1.0.1) was installed successfully
222+
Installing 'community.kubernetes:1.1.1' to '/Users/myohman/cloned-repos/ansible_modules/ansible_collections/community/kubernetes'
223+
Downloading https://galaxy.ansible.com/download/community-kubernetes-1.1.1.tar.gz to /Users/myohman/.ansible/tmp/ansible-local-4390k59zwzli/tmp5871aum5
224+
community.kubernetes (1.1.1) was installed successfully
225+
ERROR:antsibull:error=Cannot find plugin:func=get_ansible_plugin_info:mod=antsibull.docs_parsing.ansible_internal:plugin_name=netbox.netbox.netbox_interface:plugin_type=module|Error while extracting documentation. Will not document this plugin.
226+
196227
We'll push these up and let the CI/CD run and then these tests should pass and then we're good to submit a PR.

docs/getting_started/how-to-use/modules.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The next step is to then compare the object obtained from NetBox to the data pas
7979
Hopefully this helps paint a picture as to why certain design decisions were made and how you can better consume this collection. Let's move onto some examples.
8080

8181
State: Present - Create
82-
+++++++++++++++++
82+
+++++++++++++++++++++++++++++
8383

8484
When creating an object, you will need to provide the same arguments as you would if you were creating an object via the API.
8585

@@ -143,7 +143,7 @@ For reference, here is the code that **slugifies** the ``name`` argument when a
143143
Now that we have a better understanding of why certain arguments are required or not, let's look into updating an existing object.
144144

145145
State: Present - Update
146-
+++++++++++++++++
146+
+++++++++++++++++++++++++++++
147147

148148
Now that we have created our device (**Test Device**), let's update it by adding a serial number.
149149

@@ -173,7 +173,7 @@ We're only providing the **name** which makes the device unique and then the arg
173173

174174

175175
State: Absent - Delete
176-
+++++++++++++++++
176+
+++++++++++++++++++++++++++++
177177

178178
The uniqueness of the device (**name** or user specified **query_params**) and the ``state`` set to ``absent`` are the only requirements for deleting an object.
179179

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ Contents
1717
Getting Started <getting_started/index>
1818
Advanced Usage <advanced/index>
1919
Plugins <plugins/index>
20+
Module Utils (Python) Docs <module_utils/index>
2021
Changelog <changelog/index>
File renamed without changes.

0 commit comments

Comments
 (0)