Skip to content

Commit

Permalink
Added help for the error levels
Browse files Browse the repository at this point in the history
  • Loading branch information
set-soft committed Aug 30, 2023
1 parent 572204a commit 32fff15
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Camera option to set the clip start (#484)
- Populate:
- Basic support for regular list items (#480)
- Help for the error levels

### Changed
- Documentation:
Expand Down
5 changes: 4 additions & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ source/configuration/sup_outputs.rst: ../kibot/out_*.py ../kibot/config_reader.p
source/dependencies.rst: ../kibot/out_*.py ../kibot/pre_*.py ../kibot/var_*.py ../kibot/registrable.py ../kibot/misc.py ../kibot/config_reader.py ../kibot/dep_downloader.py
../src/kibot --rst --help-dependencies > $@

source/errors.rst: ../kibot/misc.py ../kibot/config_reader.py
../src/kibot --rst --help-errors > $@

source/usage.txt: ../kibot/__main__.py
../src/kibot --help > $@

Expand All @@ -48,7 +51,7 @@ help:
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
$(SPHINXTARGETS): Makefile source/configuration/sup_outputs.rst source/dependencies.rst source/usage.txt source/configuration/sup_preflights.rst \
source/configuration/sup_filters.rst source/configuration/sup_variants.rst source/configuration/sup_globals.rst
source/configuration/sup_filters.rst source/configuration/sup_variants.rst source/configuration/sup_globals.rst source/errors.rst
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)


Expand Down
40 changes: 40 additions & 0 deletions docs/source/errors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.. Automatically generated by KiBot, please don't edit this file
Supported error levels
~~~~~~~~~~~~~~~~~~~~~~

- 0: NONE
- 1: INTERNAL_ERROR
- 2: WRONG_ARGUMENTS
- 3: UNSUPPORTED_OPTION
- 4: MISSING_TOOL
- 5: DRC_ERROR
- 6: EXIT_BAD_ARGS
- 7: EXIT_BAD_CONFIG
- 8: NO_PCB_FILE
- 9: NO_SCH_FILE
- 10: ERC_ERROR
- 11: BOM_ERROR
- 12: PDF_SCH_PRINT
- 13: PDF_PCB_PRINT
- 14: PLOT_ERROR
- 15: NO_YAML_MODULE
- 16: NO_PCBNEW_MODULE
- 17: CORRUPTED_PCB
- 18: KICAD2STEP_ERR
- 19: WONT_OVERWRITE
- 20: PCBDRAW_ERR
- 21: SVG_SCH_PRINT
- 22: CORRUPTED_SCH
- 23: WRONG_INSTALL
- 24: RENDER_3D_ERR
- 25: FAILED_EXECUTE
- 26: KICOST_ERROR
- 27: MISSING_WKS
- 28: MISSING_FILES
- 29: DIFF_TOO_BIG
- 30: NETLIST_DIFF
- 31: PS_SCH_PRINT
- 32: DXF_SCH_PRINT
- 33: HPGL_SCH_PRINT
- 34: CORRUPTED_PRO
3 changes: 3 additions & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,6 @@ Command line help

.. literalinclude:: usage.txt


.. include:: errors.rst

2 changes: 2 additions & 0 deletions docs/source/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Usage:
kibot [-v...] [--rst] --help-preflights
kibot [-v...] [--rst] --help-variants
kibot [-v...] --help-banners
kibot [-v...] [--rst] --help-errors
kibot -h | --help
kibot --version

Expand Down Expand Up @@ -74,6 +75,7 @@ Help options:
-h, --help Show this help message and exit
--help-banners Show all available banners
--help-dependencies List dependencies in human readable format
--help-errors List of error levels
--help-filters List supported filters and details
--help-global-options List supported global variables
--help-list-outputs List supported outputs
Expand Down
8 changes: 7 additions & 1 deletion kibot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
kibot [-v...] [--rst] --help-preflights
kibot [-v...] [--rst] --help-variants
kibot [-v...] --help-banners
kibot [-v...] [--rst] --help-errors
kibot -h | --help
kibot --version
Expand Down Expand Up @@ -81,6 +82,7 @@
-h, --help Show this help message and exit
--help-banners Show all available banners
--help-dependencies List dependencies in human readable format
--help-errors List of error levels
--help-filters List supported filters and details
--help-global-options List supported global variables
--help-list-outputs List supported outputs
Expand Down Expand Up @@ -125,7 +127,8 @@
from .pre_base import BasePreFlight
from .error import KiPlotConfigurationError, config_error
from .config_reader import (CfgYamlReader, print_outputs_help, print_output_help, print_preflights_help, create_example,
print_filters_help, print_global_options_help, print_dependencies, print_variants_help)
print_filters_help, print_global_options_help, print_dependencies, print_variants_help,
print_errors)
from .kiplot import (generate_outputs, load_actions, config_output, generate_makefile, generate_examples, solve_schematic,
solve_board_file, solve_project_file, check_board_file)
from .registrable import RegOutput
Expand Down Expand Up @@ -458,6 +461,9 @@ def main():
logger.info('Banner '+str(c))
logger.info(b)
sys.exit(0)
if args.help_errors:
print_errors(args.rst)
sys.exit(0)
if args.example:
check_board_file(args.board_file)
if args.copy_options and not args.board_file:
Expand Down
12 changes: 9 additions & 3 deletions kibot/config_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from .error import KiPlotConfigurationError, config_error
from .misc import (NO_YAML_MODULE, EXIT_BAD_ARGS, EXAMPLE_CFG, WONT_OVERWRITE, W_NOOUTPUTS, W_UNKOUT, W_NOFILTERS,
W_NOVARIANTS, W_NOGLOBALS, TRY_INSTALL_CHECK, W_NOPREFLIGHTS, W_NOGROUPS, W_NEWGROUP)
W_NOVARIANTS, W_NOGLOBALS, TRY_INSTALL_CHECK, W_NOPREFLIGHTS, W_NOGROUPS, W_NEWGROUP, error_level_to_name)
from .gs import GS
from .registrable import RegOutput, RegVariant, RegFilter, RegDependency
from .pre_base import BasePreFlight
Expand Down Expand Up @@ -948,7 +948,7 @@ def print_output_help(name):
print_one_out_help(True, name, RegOutput.get_class_for(name))


def make_title(rst, tp, n):
def make_title(rst, tp, n, sub='^'):
global rst_mode
rst_mode = rst
logger.debug('{} supported {}'.format(n, tp))
Expand All @@ -957,7 +957,7 @@ def make_title(rst, tp, n):
title = 'Supported '+tp
print(title)
if rst_mode:
print((len(title)*'^')+'\n')
print((len(title)*sub)+'\n')
return 3, ' '
print()
return 2, ''
Expand Down Expand Up @@ -1348,3 +1348,9 @@ def print_dependencies(markdown=True, jsn=False, rst=False):
for c, rst_img in enumerate(rst_images):
print(f'.. |image{c+1}| image:: {rst_img[0]}\n :target: {rst_img[1]}')
print()


def print_errors(rst):
make_title(rst, 'error levels', len(error_level_to_name), '~')
for c, n in enumerate(error_level_to_name):
print(f'- {c}: {n}')
4 changes: 2 additions & 2 deletions kibot/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# Error levels
INTERNAL_ERROR = 1 # Unhandled exceptions
WRONG_ARGUMENTS = 2 # This is what argsparse uses
USUPPORTED_OPTION = 3
UNSUPPORTED_OPTION = 3
MISSING_TOOL = 4
DRC_ERROR = 5
EXIT_BAD_ARGS = 6
Expand Down Expand Up @@ -48,7 +48,7 @@
error_level_to_name = ['NONE',
'INTERNAL_ERROR',
'WRONG_ARGUMENTS',
'USUPPORTED_OPTION',
'UNSUPPORTED_OPTION',
'MISSING_TOOL',
'DRC_ERROR',
'EXIT_BAD_ARGS',
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ignore = E402, E226, E126, W504
# docstrings - text style (imperative, dot)
D4
max-line-length = 127
max-complexity = 30
max-complexity = 40
exclude = experiments/kicad/v6/
experiments/JLC/
experiments/resistor_colors/
Expand Down

0 comments on commit 32fff15

Please sign in to comment.