diff --git a/manual/cli-options-header.rst b/manual/cli-options-header.rst new file mode 100644 index 0000000000..f8808c230c --- /dev/null +++ b/manual/cli-options-header.rst @@ -0,0 +1,2 @@ +[options] +---------------- diff --git a/manual/conf.py b/manual/conf.py index 46c0cb10fc..e88907b4b1 100644 --- a/manual/conf.py +++ b/manual/conf.py @@ -41,9 +41,10 @@ source_suffix = '.rst' master_doc = 'index' if tags.has('online') else 'simple_index' # noqa # kill the warning about index/simple_index not being in a toctree exclude_patterns = ['simple_index.rst'] if master_doc == 'index' else ['index.rst'] +exclude_patterns.append('cli-options-header.rst') if tags.has('gettext'): # noqa - # Do not exclude simple_index as its string must be translated. This will - # generate a warning about simple_index not being in a toctree, just ignore + # Do not exclude anything as the strings must be translated. This will + # generate a warning about the documents not being in a toctree, just ignore # it. exclude_patterns = [] diff --git a/manual/custom.py b/manual/custom.py index 6bd2617d20..c3c12f4326 100644 --- a/manual/custom.py +++ b/manual/custom.py @@ -26,7 +26,7 @@ def source_read_handler(app, docname, source): src = re.sub(r'(\s+generated/)en/', r'\1' + app.config.language + '/', src) # Sphinx does not call source_read_handle for the .. include directive for m in reversed(tuple(include_pat.finditer(src))): - ss = [open(m.group(1)).read().decode('utf-8')] + ss = [open(m.group(1).lstrip('/')).read().decode('utf-8')] source_read_handler(app, m.group(1).partition('.')[0], ss) src = src[:m.start()] + ss[0] + src[m.end():] source[0] = src @@ -176,7 +176,7 @@ def update_cli_doc(name, raw, app): def render_options(cmd, groups, options_header=True, add_program=True, header_level='~'): lines = [''] if options_header: - lines = ['[options]', '-'*15, ''] + lines = ['.. include:: /cli-options-header.rst', ''] if add_program: lines += ['.. program:: '+cmd, ''] for title, desc, options in groups: diff --git a/src/calibre/debug.py b/src/calibre/debug.py index 98143e58b4..a75d4d0e9d 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -28,7 +28,7 @@ You can also use %prog to run standalone scripts. To do that use it like this: {1} Everything after the -- is passed to the script. -''').format('%prog [options]', '%prog myscript.py -- --option1 --option2 file1 file2 ...')) +''').format(_('%prog [options]'), '%prog myscript.py -- --option1 --option2 file1 file2 ...')) parser.add_option('-c', '--command', help=_('Run python code.')) parser.add_option('-e', '--exec-file', help=_('Run the python code in file.')) parser.add_option('-f', '--subset-font', action='store_true', default=False, diff --git a/src/calibre/ebooks/metadata/cli.py b/src/calibre/ebooks/metadata/cli.py index 5ffc84bbf6..cb17937a9d 100644 --- a/src/calibre/ebooks/metadata/cli.py +++ b/src/calibre/ebooks/metadata/cli.py @@ -17,7 +17,7 @@ from calibre.ebooks.lrf.meta import LRFMetaFile from calibre import prints from calibre.utils.date import parse_date -USAGE='%%prog ebook_file [' + _('options') + ']\n' + \ +USAGE=_('%%prog ebook_file [' + _('options') + ']\n') + \ _(''' Read/Write metadata from/to ebook files. diff --git a/src/calibre/ebooks/oeb/polish/main.py b/src/calibre/ebooks/oeb/polish/main.py index 4aeb099f9f..d60a3151d1 100644 --- a/src/calibre/ebooks/oeb/polish/main.py +++ b/src/calibre/ebooks/oeb/polish/main.py @@ -263,7 +263,7 @@ def tweak_polish(container, actions, customization=None): def option_parser(): from calibre.utils.config import OptionParser - USAGE = '%prog [options] input_file [output_file]\n\n' + re.sub( + USAGE = _('%prog [options] input_file [output_file]\n\n') + re.sub( r'<.*?>', '', CLI_HELP['about']) parser = OptionParser(usage=USAGE) a = parser.add_option diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 5775d00cba..d02d5784da 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -27,7 +27,7 @@ class AbortInit(Exception): def option_parser(): parser = _option_parser(_('''\ -%prog [opts] [path_to_ebook] +%prog [options] [path_to_ebook] Launch the main calibre Graphical User Interface and optionally add the ebook at path_to_ebook to the database.