Skip to content

Commit

Permalink
Add error handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Mar 31, 2024
1 parent 994ca15 commit 7fef250
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/antsibull_docs/cli/doc_commands/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def generate_plugin_docs(
)
except CalledProcessError as exc:
err_msg = []
formatted_exception = traceback.format_exception(None, exc, exc.__traceback__)
formatted_exception = traceback.format_exception(exc)
err_msg.append(
f"Exception while parsing documentation for {plugin_type} plugin:"
f" {plugin_name}. Will not document this plugin."
Expand Down
58 changes: 33 additions & 25 deletions src/antsibull_docs/write_docs/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,39 @@ async def write_changelog(
flog = mlog.fields(func="write_changelog")
flog.debug("Enter")

paths = PathsConfig.force_collection(collection_metadata.path)

collection_details = CollectionDetails(paths)
collection_details.namespace, collection_details.name = collection_name.split(
".", 1
)
collection_details.version = collection_metadata.version
collection_details.flatmap = collection_metadata.docs_config.flatmap

config = ChangelogConfig.default(paths, collection_details)
config.title = collection_name.title()
config.use_fqcn = True
config.mention_ancestor = True
config.flatmap = collection_metadata.docs_config.flatmap

changes = load_changes(config)

generator = ChangelogGenerator(config, changes)

renderer = create_document_renderer(output_format.changelog_format)
generator.generate(renderer)

changelog_contents = renderer.render()
for warning in renderer.get_warnings():
flog.warning(warning)
try:
paths = PathsConfig.force_collection(collection_metadata.path)

collection_details = CollectionDetails(paths)
collection_details.namespace, collection_details.name = collection_name.split(
".", 1
)
collection_details.version = collection_metadata.version
collection_details.flatmap = collection_metadata.docs_config.flatmap

config = ChangelogConfig.default(paths, collection_details)
config.title = collection_name.title()
config.use_fqcn = True
config.mention_ancestor = True
config.flatmap = collection_metadata.docs_config.flatmap

changes = load_changes(config)

generator = ChangelogGenerator(config, changes)

renderer = create_document_renderer(output_format.changelog_format)
generator.generate(renderer)

changelog_contents = renderer.render()
for warning in renderer.get_warnings():
flog.warning(warning)
except Exception as exc: # pylint: disable=broad-exception-caught
flog.warning(f"Error while processing changelog for {collection_name}: {exc}")
changelog_contents = f"""
The changelog of {collection_name} could not be rendered::
{exc}
"""

changelog_file = os.path.join(
collection_dir, f"changelog{output_format.output_extension}"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

The changelog of ns2.col could not be rendered::

list index out of range
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ Communication
.. toctree::
:maxdepth: 1

Changelog
---------

.. toctree::
:maxdepth: 1

changelog

Guides
------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

The changelog of ns2.col could not be rendered::

list index out of range
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ Communication
.. toctree::
:maxdepth: 1

Changelog
---------

.. toctree::
:maxdepth: 1

changelog

Guides
------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

The changelog of ns2.col could not be rendered::

list index out of range
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ Communication
.. toctree::
:maxdepth: 1

Changelog
---------

.. toctree::
:maxdepth: 1

changelog

Guides
------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

The changelog of ns2.col could not be rendered::

list index out of range
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Communication
- Mailing list: `Ansible Project List <https://groups.google.com/g/ansible-project>`__.
(`Subscribe <mailto:[email protected]?subject=subscribe>`__)

Changelog
---------

`Ns2.Col Release Notes <changelog.rst>`_

Guides
------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

The changelog of ns2.col could not be rendered::

list index out of range
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Communication
- Mailing list: `Ansible Project List <https://groups.google.com/g/ansible-project>`__.
(`Subscribe <mailto:[email protected]?subject=subscribe>`__)

Changelog
---------

`Ns2.Col Release Notes <changelog.rst>`_

Guides
------
Expand Down
4 changes: 4 additions & 0 deletions tests/functional/baseline-squash-hierarchy/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

The changelog of ns2.col could not be rendered::

list index out of range
7 changes: 7 additions & 0 deletions tests/functional/baseline-squash-hierarchy/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ Communication
.. toctree::
:maxdepth: 1

Changelog
---------

.. toctree::
:maxdepth: 1

changelog

Guides
------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

The changelog of ns2.col could not be rendered::

list index out of range
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ Communication
.. toctree::
:maxdepth: 1

Changelog
---------

.. toctree::
:maxdepth: 1

changelog

Guides
------
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

releases:
- 1
- 2
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
envvar_directives:
- FOOBAR1
- FOOBAR2

changelog:
write_changelog: true

0 comments on commit 7fef250

Please sign in to comment.