consolidate to single arguments file

pull/120/head
Dan Joseph 2021-11-11 18:26:07 -05:00
rodzic da96707553
commit fa5e3e1efa
5 zmienionych plików z 1777 dodań i 222 usunięć

Wyświetl plik

@ -1,10 +1,5 @@
..
AUTO-GENERATED by extract_odm_strings.py! DO NOT EDIT!
If you want to add more details to a command, create a
.rst file in arguments_edit/<argument>.rst
.. _$opt:
$ticks
$opt
$ticks
@ -12,6 +7,12 @@ $parameter
$descr
$include
$edit
`Learn to edit <https://github.com/opendronemap/docs#how-to-make-your-first-contribution>`_ and help improve `this page <https://github.com/OpenDroneMap/docs/blob/publish/source/$editfile>`_!
.. raw:: html
<br>
<hr style="border-top: 6px double #8c8b8b">
<br>
<br>

Wyświetl plik

@ -1,13 +1,18 @@
..
AUTO-GENERATED by extract_odm_strings.py! DO NOT EDIT!
If you want to add more details to a command, edit a
.rst file in arguments_edit/<argument>.rst
#################
Options and Flags
-----------------
#################
$arguments
If you want to add more details to a command, `learn to edit <https://github.com/opendronemap/docs#how-to-make-your-first-contribution>`_ and help improve the matching file in the ``arguments_edit`` `project folder <https://github.com/OpenDroneMap/docs/tree/publish/source/arguments_edit>`_!
.. raw:: html
`Learn to edit <https://github.com/opendronemap/docs#how-to-make-your-first-contribution>`_ and help improve `this page <https://github.com/OpenDroneMap/docs/blob/publish/source/arguments.rst>`_!
.. toctree::
:maxdepth: 1
:glob:
arguments/*
<br>
<hr style="border-top: 6px double #8c8b8b">
<br>
<br>

Wyświetl plik

@ -3,6 +3,7 @@
import argparse, os, urllib.request, ast, sys
from io import StringIO
from string import Template
from pathlib import Path
parser = argparse.ArgumentParser(description='Extract ODM strings.')
parser.add_argument('input', type=str,
@ -31,13 +32,13 @@ class ArgumentParserStub(argparse.ArgumentParser):
for name, value in kwargs.items():
options[args[0]][str(name)] = str(value)
def add_mutually_exclusive_group(self):
return ArgumentParserStub()
# Voodoo! :)
# ( parse AST, extract "def config()" function, set module to only
# contain that function, execute module in current scope,
# contain that function, execute module in current scope,
# run config function)
root = ast.parse(config_file)
new_body = []
@ -56,7 +57,7 @@ exec(compile(root, filename="<ast>", mode="exec"))
# Misc variables needed to get config to run
__version__ = '?'
class context:
class context:
root_path = ''
num_cores = 4
class io:
@ -88,7 +89,7 @@ if len(options) > 0:
keys = list(options.keys())
keys.sort(key=lambda a: a.replace("-", ""))
with open(argstmplfile) as f:
argstmpl = Template(f.read())
@ -99,14 +100,14 @@ if len(options) > 0:
# Use longest name
opt_name = max(arg_map + (opt_name, ), key=len)
return opt_name.replace("--", "")
def get_opt_descr(opt):
return options[opt].get('help', '').replace("*", "\*")
def get_opt_choices(opt):
return options[opt].get('choices', options[opt].get('metavar', '')).replace('[', '').replace(']', '').replace(',', ' | ').replace('\'', '')
for opt in keys:
for idx,opt in enumerate(keys):
opt_name = get_opt_name(opt)
include_file = os.path.join(argsoutdir + "_edit", "%s.rst" % opt_name)
@ -115,37 +116,27 @@ if len(options) > 0:
f.write("\n")
print("Wrote %s" % include_file)
argument_edit = Path(include_file).read_text()
kwargs = {
'opt': opt_name,
'ticks': '`' * len(opt_name),
'ticks': '*' * len(opt_name),
'descr': get_opt_descr(opt),
'parameter': "**Options:** *%s*" % get_opt_choices(opt) if get_opt_choices(opt) else "",
'include': ".. include:: ../arguments_edit/%s" % os.path.basename(include_file),
# 'include': ".. include:: ../arguments_edit/%s" % os.path.basename(include_file),
'editfile': os.path.join("arguments_edit", os.path.basename(include_file)),
'edit': argument_edit,
}
argsoutfile = os.path.join(argsoutdir, opt_name + ".rst")
with open(argsoutfile, "w") as f:
f.write(argstmpl.substitute(**kwargs))
print("Wrote %s" % argsoutfile)
arg = argstmpl.substitute(**kwargs)
for opt in keys:
subst += ":ref:`%s<%s>` %s\n %s\n\n" % (
get_opt_name(opt),
get_opt_name(opt),
get_opt_choices(opt),
get_opt_descr(opt)
)
with open(tmplfile) as f:
tmpl = Template(f.read())
with open(outfile, "w") as f:
f.write(tmpl.substitute(arguments=subst))
print("Wrote %s" % outfile)
if idx == 0:
header = Path(tmplfile).read_text()
with open(outfile, "w") as f:
f.write(header)
with open(outfile, "a") as f:
f.write(arg)
else:
print("No strings found")
print("No strings found")

Plik diff jest za duży Load Diff

Wyświetl plik

@ -62,7 +62,7 @@ language = 'en'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'arguments_edit']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'