Commit e864be4c authored by Jakub Ružička's avatar Jakub Ružička
Browse files

docs: add new errors.md

Fixes: #35
parent 7fd3c278
Pipeline #78469 passed with stages
in 2 minutes and 23 seconds
""" """
generate docs from apkg code/docstrings using mkdocs-macros-plugin generate docs from apkg code/docstrings using mkdocs-macros-plugin
""" """
import inspect
from apkg import ex
from apkg import pkgstyle from apkg import pkgstyle
from apkg.cli import cmd2mod from apkg.cli import cmd2mod
from pathlib import Path from pathlib import Path
...@@ -17,6 +20,7 @@ def define_env(env): ...@@ -17,6 +20,7 @@ def define_env(env):
""" """
env.variables.pkgstyles = pkgstyle.PKGSTYLES env.variables.pkgstyles = pkgstyle.PKGSTYLES
env.variables.new_issue_url = APKG_NEW_ISSUE_URL env.variables.new_issue_url = APKG_NEW_ISSUE_URL
env.variables.exceptions = get_exceptions()
@env.filter @env.filter
def relpath(path): def relpath(path):
...@@ -43,3 +47,12 @@ def define_env(env): ...@@ -43,3 +47,12 @@ def define_env(env):
modname = 'apkg.commands.%s' % cmd2mod(cmd) modname = 'apkg.commands.%s' % cmd2mod(cmd)
return "``` text\n$> apkg %s --help\n\n%s\n```" % ( return "``` text\n$> apkg %s --help\n\n%s\n```" % (
cmd, mod_doc(modname)) cmd, mod_doc(modname))
def get_exceptions():
"""
return all apkg exceptions sorted by exit_code
"""
exs = [e for _, e in inspect.getmembers(ex, inspect.isclass)]
exs.sort(key=lambda x: x.exit_code)
return exs
# apkg errors
`apkg` communicates errors using custom exceptions in
{{ 'apkg/ex.py' | file_link }}.
Each exception contains message explaining what went wrong as well as
`exit_code` to return in case it's raised during CLI run.
A list of all `apkg` errors/exceptions with their default error message
sorted by exit code:
{% for e in exceptions %}
### {{ e.__name__}}
```text
{{ e.msg_fmt }}
```
exit code: `{{ e.exit_code }}`
{% endfor %}
...@@ -9,6 +9,7 @@ nav: ...@@ -9,6 +9,7 @@ nav:
- config.md - config.md
- pkgstyles.md - pkgstyles.md
- templates.md - templates.md
- errors.md
markdown_extensions: markdown_extensions:
- admonition - admonition
- toc: - toc:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment