diff --git a/README.md b/README.md index 62863eb..9861fde 100644 --- a/README.md +++ b/README.md @@ -151,10 +151,10 @@ python roentgen.py render -b 2.284,48.86,2.29,48.865 | `-i`, `--input` | input XML file name or names (if not specified, file will be downloaded using OpenStreetMap API) | | `-o`, `--output` | output SVG file name, default value: `out/map.svg` | | `-b`, `--boundary-box` | geo boundary box, use space before "-" if the first value is negative | -| `-s`, `--scale` | OSM zoom level (may not be integer), default value: `18` | +| `-s`, `--scale` | OSM zoom level (may not be integer), default value: 18 | | `--cache` | path for temporary OSM files, default value: `cache` | | `--labels` | label drawing mode: `no`, `main`, or `all`, default value: `main` | -| `--overlap` | how many pixels should be left around icons and text, default value: `12` | +| `--overlap` | how many pixels should be left around icons and text, default value: 12 | | `--mode` | map drawing mode, default value: `normal` | | `--seed` | seed for random | | `--level` | display only this floor level | @@ -168,7 +168,7 @@ Command: `tile`. |---|---| | `-h`, `--help` | show this help message and exit | | `-c`, `--coordinates` | coordinates of any location inside the tile | -| `-s`, `--scale` | OSM zoom level, default value: `18` | +| `-s`, `--scale` | OSM zoom level, default value: 18 | | `-t`, `--tile` | tile specification | | `--cache` | path for temporary OSM files, default value: `cache` | diff --git a/roentgen/moire_manager.py b/roentgen/moire_manager.py index 452d506..8e3ca17 100644 --- a/roentgen/moire_manager.py +++ b/roentgen/moire_manager.py @@ -10,7 +10,7 @@ from moire.default import Default, DefaultHTML, DefaultMarkdown, DefaultWiki from roentgen import workspace from roentgen.icon import ShapeExtractor from pathlib import Path -from typing import Dict, List, Any +from typing import Dict, List, Any, Union import yaml from roentgen import ui @@ -19,6 +19,7 @@ __author__ = "Sergey Vartanov" __email__ = "me@enzet.ru" Arguments = List[Any] +Code = Union[str, Tag, List] PREFIX: str = "https://wiki.openstreetmap.org/wiki/" @@ -29,7 +30,7 @@ class ArgumentParser(argparse.ArgumentParser): """ def __init__(self, *args, **kwargs): - self.arguments = [] + self.arguments: List[Dict[str, Any]] = [] super(ArgumentParser, self).__init__(*args, **kwargs) def add_argument(self, *args, **kwargs) -> None: @@ -43,12 +44,15 @@ class ArgumentParser(argparse.ArgumentParser): self.arguments.append(argument) def get_moire_help(self) -> Tag: - """Return Moire table with stored arguments.""" + """ + Return Moire table with "Option" and "Description" columns filled with + arguments. + """ table = [[["Option"], ["Description"]]] for option in self.arguments: - array = [[Tag("m", [x]), ", "] for x in option["arguments"]] - row = [[x for y in array for x in y][:-1]] + array: Code = [[Tag("m", [x]), ", "] for x in option["arguments"]] + row: Code = [[x for y in array for x in y][:-1]] if "help" in option: help_value: List = [option["help"]] @@ -57,14 +61,16 @@ class ArgumentParser(argparse.ArgumentParser): and option["default"] and option["default"] != "==SUPPRESS==" ): - help_value += [ - ", default value: ", - Tag("m", [str(option["default"])]), - ] + default_value: Code = Tag("m", [str(option["default"])]) + if "type" in option and option["type"] in [int, float]: + default_value = str(option["default"]) + help_value += [", default value: ", default_value] row.append(help_value) else: row.append([]) + table.append(row) + return Tag("table", table)