update makefile and change argument file generation

pull/121/head
Dan Joseph 2021-11-12 16:26:15 -05:00
rodzic 1fd18ded70
commit 372a9e51b3
4 zmienionych plików z 44 dodań i 28 usunięć

Wyświetl plik

@ -14,28 +14,41 @@ help:
.PHONY: help Makefile
# this is for testing, it will only build the EN version of the docs
livehtml:
sphinx-autobuild --open-browser --host 0.0.0.0 -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)/html"
# this will update `arguments.rst` to match arguments in the ODM code
# add any individual file for an arguement missing from `source/arguments_edit/`
# update the files in `source/arguments/` including adding in
# all user contributed content from files in `source/arguments_edit/`
autogenerate:
python scripts/extract_odm_strings.py https://raw.githubusercontent.com/OpenDroneMap/ODM/master/opendm/config.py
pushlang:
@$(SPHINXBUILD) -b gettext "$(SOURCEDIR)" "source/locale/en/pot"
tx push --source
pulllang:
tx pull --language "sw,ar,es,fr,te,fil"
# update main EN pot files that serve as the source for translation process
updatepot:
@$(SPHINXBUILD) -b gettext "$(SOURCEDIR)" "source/locale/pot"
livehtml:
sphinx-autobuild --open-browser --host 0.0.0.0 -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)"
# update the po files for each target language from the EN pot files
updatelangpo:
sphinx-intl update --pot-dir "source/locale/pot" --language sw,ar,es,fr,te,fil
# push new and changed strings to Transifex
pushlang:
tx push --source
# push translated strings from Transifex
pulllang:
tx pull --language "sw,ar,es,fr,te,fil"
build:
@$(SPHINXBUILD) -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)/html" -nW
@$(SPHINXBUILD) -b dirhtml -D language='sw' "$(SOURCEDIR)" "$(BUILDDIR)/html/sw" -nW
@$(SPHINXBUILD) -b dirhtml -D language='ar' "$(SOURCEDIR)" "$(BUILDDIR)/html/ar" -nW
@$(SPHINXBUILD) -b dirhtml -D language='sw' "$(SOURCEDIR)" "$(BUILDDIR)/html/sw" -nW
@$(SPHINXBUILD) -b dirhtml -D language='ar' "$(SOURCEDIR)" "$(BUILDDIR)/html/ar" -nW
@$(SPHINXBUILD) -b dirhtml -D language='es' "$(SOURCEDIR)" "$(BUILDDIR)/html/es" -nW
@$(SPHINXBUILD) -b dirhtml -D language='fr' "$(SOURCEDIR)" "$(BUILDDIR)/html/fr" -nW
@$(SPHINXBUILD) -b dirhtml -D language='te' "$(SOURCEDIR)" "$(BUILDDIR)/html/te" -nW
@$(SPHINXBUILD) -b dirhtml -D language='fil' "$(SOURCEDIR)" "$(BUILDDIR)/html/fil" -nW
echo "docs.opendronemap.org" > ./_build/html/CNAME
# -n Run in nit-picky mode. Currently, this generates warnings for all missing references.
# -W Turn warnings into errors that stop the build.
# for more details about the options see https://www.sphinx-doc.org/en/1.8/man/sphinx-build.html#options
@ -43,13 +56,13 @@ build:
# `allerr` runs without nit-picky mode, so that an error doesn't halt the build
# it will log all errors that need to be fixed in the translations (generally syntax errors)
allerr:
@$(SPHINXBUILD) -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)/html"
@$(SPHINXBUILD) -b dirhtml -D language='sw' "$(SOURCEDIR)" "$(BUILDDIR)/html/sw"
@$(SPHINXBUILD) -b dirhtml -D language='ar' "$(SOURCEDIR)" "$(BUILDDIR)/html/ar"
@$(SPHINXBUILD) -b dirhtml -D language='es' "$(SOURCEDIR)" "$(BUILDDIR)/html/es"
@$(SPHINXBUILD) -b dirhtml -D language='fr' "$(SOURCEDIR)" "$(BUILDDIR)/html/fr"
@$(SPHINXBUILD) -b dirhtml -D language='te' "$(SOURCEDIR)" "$(BUILDDIR)/html/te"
@$(SPHINXBUILD) -b dirhtml -D language='fil' "$(SOURCEDIR)" "$(BUILDDIR)/html/fil"
@$(SPHINXBUILD) -v -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)/html"
@$(SPHINXBUILD) -v -b dirhtml -D language='sw' "$(SOURCEDIR)" "$(BUILDDIR)/html/sw"
@$(SPHINXBUILD) -v -b dirhtml -D language='ar' "$(SOURCEDIR)" "$(BUILDDIR)/html/ar"
@$(SPHINXBUILD) -v -b dirhtml -D language='es' "$(SOURCEDIR)" "$(BUILDDIR)/html/es"
@$(SPHINXBUILD) -v -b dirhtml -D language='fr' "$(SOURCEDIR)" "$(BUILDDIR)/html/fr"
@$(SPHINXBUILD) -v -b dirhtml -D language='te' "$(SOURCEDIR)" "$(BUILDDIR)/html/te"
@$(SPHINXBUILD) -v -b dirhtml -D language='fil' "$(SOURCEDIR)" "$(BUILDDIR)/html/fil"
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).

Wyświetl plik

@ -1,6 +1,6 @@
..
AUTO-GENERATED by extract_odm_strings.py! DO NOT EDIT!
If you want to add more details to a command, create a
If you want to add more details to a command, edit a
.rst file in arguments_edit/<argument>.rst
.. _$opt:

Wyświetl plik

@ -4,10 +4,10 @@ Options and Flags
$arguments
`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>`_!
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>`_!
.. toctree::
:maxdepth: 1
:glob:
arguments/*
arguments/*

Wyświetl plik

@ -2,6 +2,7 @@
import argparse, os, urllib.request, ast, sys
from io import StringIO
from pathlib import Path
from string import Template
parser = argparse.ArgumentParser(description='Extract ODM strings.')
@ -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,10 +100,10 @@ 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('\'', '')
@ -115,12 +116,14 @@ 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),
'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': argument_edit,
'editfile': os.path.join("arguments_edit", os.path.basename(include_file)),
}
@ -148,4 +151,4 @@ if len(options) > 0:
else:
print("No strings found")
print("No strings found")