Skip to content

Commit

Permalink
docs: improve conversion from LaTex to Sphinx/RST
Browse files Browse the repository at this point in the history
  * include image from /_static/images/ directory
    (which links to existing directory with converted images)
  * include configuration examples from /_static/config/ directory
    (which links to existing directory of the old documentation)
  * create links to existing include files in the old documentation
  * ignore \pagebreak command
  * cover \trademark command
  * cover \verbatiminput command
  * cover \sdBackend command
  * fixes volumeparameter command (covers now handling of 1 or 2 arguments)
  * replace \subsubsubsection (custom command) with \paragraph in preconversion script,
    as the result will be better convertible by pandoc.
  * removed source/copyright.rst, as it is not included anywhere.
  • Loading branch information
joergsteffens committed Feb 10, 2019
1 parent 9224ad4 commit 65d02f9
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 22 deletions.
4 changes: 4 additions & 0 deletions docs/manuals/en/new_main_reference/destfiles.txt
Expand Up @@ -27,12 +27,16 @@ chapter17/recycling.tex
chapter18/pools.tex
chapter19/autochangers.tex
chapter20/tape-without-autochanger.tex
chapter20/storage-backends.tex
chapter21/spooling.tex
chapter22/migration.tex
chapter23/always-incremental.tex
chapter24/basejob.tex
chapter26/plugins.tex
chapter26/plugins-fd.tex
chapter26/plugins-vmware-plugin.tex
chapter26/plugins-sd.tex
chapter26/plugins-dir.tex
chapter27/win32.tex
chapter28/client-initiated-connection.tex
chapter28/passiveclient.tex
Expand Down
62 changes: 53 additions & 9 deletions docs/manuals/en/new_main_reference/latex-scan.py
Expand Up @@ -135,7 +135,7 @@ def __init__(self):
'idir': {
'pattern': r'\\idir\ *(.*?)\n',
'flags': re.VERBOSE,
'replace': r'images/\1.*\n'
'replace': r'/_static/images/\1.*\n'
},
'EnvBareosConfigResource': {
'pattern': r'::\n\n(\s*)\\begin{bareosConfigResource}{(.*?)}{(.*?)}{(.*?)}\s*\n(.*?)\n\s*\\end{bareosConfigResource}',
Expand Down Expand Up @@ -219,7 +219,7 @@ def __init__(self):
'pattern': r'\.\.\s\|image\|\simage::\s\\idir\s(.*?)$(.*?)(?=\n[^\s]|^$)',
'flags': self.regexOpts,
'replace': r'',
'return': r'.. image:: images/\1.*\2\n\n',
'return': r'.. image:: /_static/images/\1.*\2\n\n',
'extraHandling': True
},
}
Expand Down Expand Up @@ -621,7 +621,7 @@ def bcheckmark(item):

@staticmethod
def bconfigInput(item):
item.replace(b'.. literalinclude:: ../../main/{0}\n'.format(*item.getParameters()))
item.replace(b'\n\n.. literalinclude:: /_static/{0}\n\n'.format(*item.getParameters()))

@staticmethod
def bcommand(item):
Expand Down Expand Up @@ -743,7 +743,7 @@ def fileset(item):
#
@staticmethod
def hfill(item):
item.replace(b'')
item.replace(r'')

@staticmethod
def hide(item):
Expand Down Expand Up @@ -905,6 +905,10 @@ def package(item):
item.replace(b'**{0}**'.format(*item.getParameters()))
#${PERL} 's#:raw-latex:`\\package\{(.*?)\}`#**\1**#g' ${DESTFILE}

@staticmethod
def pagebreak(item):
item.replace(r'')

@staticmethod
def parameter(item):
# don't use :option:, as this has a special behavior, that we don't use.
Expand Down Expand Up @@ -947,6 +951,26 @@ def resourcetype(item):
#
# s
#
@staticmethod
def sdBackend(item):
#\newcommand{\sdBackend}[2]{%
#\ifthenelse{\isempty{#2}}{%
#\path|#1|%
#\index[general]{#1}%
#\index[sd]{Backend!#1}%
#}{%
#\path|#1| (#2)%
#\index[general]{#1 (#2)}%
#\index[general]{#2!#1}%
#\index[sd]{Backend!#1 (#2)}%
#}%
#}
name, backend = item.getParameters()
if backend:
item.replace(b'**{0}** ({1})'.format(name, backend))
else:
item.replace(b'**{0}**'.format(name))

@staticmethod
def sinceVersion(item):
#% 1: daemon (dir|sd|fd),
Expand Down Expand Up @@ -990,10 +1014,11 @@ def sinceVersion(item):
##sed 's#:raw-latex:`\\sinceVersion\{(.*)\}\{(.*)\}\{(.*)\}`#\n\n.. versionadded:: \3\n \1 \2\n#g' ${DESTFILE}
#${PERL} 's|:raw-latex:`\\sinceVersion\{(.*)\}\{(.*)\}\{(.*)\}`|\3|g' ${DESTFILE}

@staticmethod
def subsubsubsection(item):
name = item.getParameters()[0]
item.replace(u'{0}\n{1}\n'.format(name, len(name)*'"'))
# moved to preconversion, to avoid errors.
#@staticmethod
#def subsubsubsection(item):
# name = item.getParameters()[0]
# item.replace(u'{0}\n{1}\n'.format(name, len(name)*'"'))

#
# t
Expand All @@ -1020,6 +1045,11 @@ def ticket(item):
def TODO(item):
item.replace(r'.. TODO: {0}'.format(*item.getParameters()))

@staticmethod
def trademark(item):
# TODO: fix this
item.replace(r'\ :sup:`(TM)`')

#
# u
#
Expand All @@ -1046,7 +1076,21 @@ def volumestatus(item):

@staticmethod
def volumeparameter(item):
item.replace(b'{0} = **{1}**'.format(*item.getParameters()))
parameter, value = item.getParameters()
if value:
item.replace(b'**{0} = {1}**'.format(parameter, value))
else:
item.replace(b'**{0}**'.format(parameter))
#\newcommand{\volumeparameter}[2]{\ifthenelse{\isempty{#2}}{%
# \path|#1|%
# }{%
# \path|#1 = #2|%
#}}

@staticmethod
def verbatiminput(item):
# file must be in the source/ directory (at least there have to be a link)
item.replace(b'\n\n.. literalinclude:: /_static/{0}\n\n'.format(*item.getParameters()))


#
Expand Down
2 changes: 2 additions & 0 deletions docs/manuals/en/new_main_reference/pre_conversion_changes.sh
Expand Up @@ -27,6 +27,8 @@ DESTFILE=$2
| perl -0 -pe 's|(\\begin\{bconsole\}.*?\\end\{bconsole\})|\\begin{verbatim}\1\\end{verbatim}|smg' \
\
| perl -0 -pe 's|(\\begin\{tabular\}.*?\\end\{tabular\})|\# Tabular in LaTex format (original)\n\\begin{verbatim}\1\\end{verbatim}\n\n\# Tabular converted from LaTeX to RST (or empty, in case of problems):\n\1|smg' \
\
| perl -0 -pe 's|\\subsubsubsection\{|\\paragraph\{|g' \
\
| perl -0 -pe 's|\\releasenoteSection\{(.*?)\}|\\section*{\1}\n\n|smg' \
\
Expand Down
1 change: 1 addition & 0 deletions docs/manuals/en/new_main_reference/source/_static/agpl.txt
1 change: 1 addition & 0 deletions docs/manuals/en/new_main_reference/source/_static/config
1 change: 1 addition & 0 deletions docs/manuals/en/new_main_reference/source/_static/fdl.txt
1 change: 1 addition & 0 deletions docs/manuals/en/new_main_reference/source/_static/images
1 change: 1 addition & 0 deletions docs/manuals/en/new_main_reference/source/_static/lgpl.txt
12 changes: 0 additions & 12 deletions docs/manuals/en/new_main_reference/source/copyright.rst

This file was deleted.

1 change: 0 additions & 1 deletion docs/manuals/en/new_main_reference/source/images

This file was deleted.

0 comments on commit 65d02f9

Please sign in to comment.