Skip to content

Commit

Permalink
Merge pull request #55 from melexis/issue-54
Browse files Browse the repository at this point in the history
fix #54: more granular exception handling
  • Loading branch information
Letme authored Jul 13, 2018
2 parents 47851ed + 83e9966 commit 1ab7b1f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion example/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ This text is not part of any item

.. item:: r005 Another (does not show captions on the related items)
:class: terciary
:trace: r002 r003
:trace: r002 r002 r003
:nocaptions:

Clean up all this again
Expand Down
37 changes: 20 additions & 17 deletions mlx/traceability.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,31 @@ def run(self):
if len(self.arguments) > 1:
caption = self.arguments[1].replace('\n', ' ')

# Store item info
item = TraceableItem(targetid)
item.set_document(env.docname, self.lineno)
item.bind_node(targetnode)
item.set_caption(caption)
item.set_content('\n'.join(self.content))
try:
# Store item info
item = TraceableItem(targetid)
item.set_document(env.docname, self.lineno)
item.bind_node(targetnode)
item.set_caption(caption)
item.set_content('\n'.join(self.content))
env.traceability_collection.add_item(item)
except TraceabilityException as err:
report_warning(env, err, env.docname, self.lineno)

# Add found relationships to item. All relationship data is a string of
# item ids separated by space. It is splitted in a list of item ids
for rel in env.traceability_collection.iter_relations():
if rel in self.options:
related_ids = self.options[rel].split()
for related_id in related_ids:
# Add found relationships to item. All relationship data is a string of
# item ids separated by space. It is splitted in a list of item ids
for rel in env.traceability_collection.iter_relations():
if rel in self.options:
related_ids = self.options[rel].split()
for related_id in related_ids:
try:
env.traceability_collection.add_relation(targetid, rel, related_id)
except TraceabilityException as err:
report_warning(env, err, env.docname, self.lineno)

# Custom callback for modifying items
if app.config.traceability_callback_per_item:
app.config.traceability_callback_per_item(targetid, env.traceability_collection)
except TraceabilityException as err:
report_warning(env, err, env.docname, self.lineno)
# Custom callback for modifying items
if app.config.traceability_callback_per_item:
app.config.traceability_callback_per_item(targetid, env.traceability_collection)

# Output content of item to document
template = []
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages

project_url = 'https://github.com/melexis/sphinx-traceability-extension'
version = '2.5.1'
version = '2.5.2'

requires = ['Sphinx>=0.6', 'docutils']

Expand Down
24 changes: 12 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ whitelist_externals =
mlx-warnings
commands=
bash -c 'make -C example html 2>&1 | tee .tox/doc_html.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_html.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_html.log
bash -c 'make -C example latexpdf 2>&1 | tee .tox/doc_pdf.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_pdf.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_pdf.log

[testenv:sphinx1.4]
deps=
Expand All @@ -74,9 +74,9 @@ whitelist_externals =
mlx-warnings
commands=
bash -c 'make -C example html 2>&1 | tee .tox/doc_html.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_html.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_html.log
bash -c 'make -C example latexpdf 2>&1 | tee .tox/doc_pdf.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_pdf.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_pdf.log

[testenv:sphinx1.5]
deps=
Expand All @@ -90,9 +90,9 @@ whitelist_externals =
mlx-warnings
commands=
bash -c 'make -C example html 2>&1 | tee .tox/doc_html.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_html.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_html.log
bash -c 'make -C example latexpdf 2>&1 | tee .tox/doc_pdf.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_pdf.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_pdf.log

[testenv:sphinx1.6]
deps=
Expand All @@ -106,9 +106,9 @@ whitelist_externals =
mlx-warnings
commands=
bash -c 'make -C example html 2>&1 | tee .tox/doc_html.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_html.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_html.log
bash -c 'make -C example latexpdf 2>&1 | tee .tox/doc_pdf.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_pdf.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_pdf.log

[testenv:sphinx1.7]
deps=
Expand All @@ -122,9 +122,9 @@ whitelist_externals =
mlx-warnings
commands=
bash -c 'make -C example html 2>&1 | tee .tox/doc_html.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_html.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_html.log
bash -c 'make -C example latexpdf 2>&1 | tee .tox/doc_pdf.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_pdf.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_pdf.log

[testenv:sphinx-latest]
deps=
Expand All @@ -138,9 +138,9 @@ whitelist_externals =
mlx-warnings
commands=
bash -c 'make -C example html 2>&1 | tee .tox/doc_html.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_html.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_html.log
bash -c 'make -C example latexpdf 2>&1 | tee .tox/doc_pdf.log'
mlx-warnings --sphinx --maxwarnings 6 --minwarnings 6 .tox/doc_pdf.log
mlx-warnings --sphinx --maxwarnings 7 --minwarnings 7 .tox/doc_pdf.log

[testenv:coveralls]
deps =
Expand Down

0 comments on commit 1ab7b1f

Please sign in to comment.