Skip to content

Commit

Permalink
Merge branch 'master' of github.com:yjacolin/QGIS-Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
yjacolin committed Apr 15, 2012
2 parents b480916 + edfbf5b commit dc0f7df
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ Thumb.db
desktop.ini desktop.ini
*.*~ *.*~
*~ *~
build

64 changes: 41 additions & 23 deletions latex2rst.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import re import re
from optparse import OptionParser from optparse import OptionParser


supplement = {"footnote": [], }
def repl1(obj): def repl1(obj):
eq = obj.group(1) eq = obj.group(1)
eq = eq.replace("\n", " ") eq = eq.replace("\n", " ")
Expand All @@ -31,7 +32,8 @@ def item(obj):
return l return l
def footnote(obj): def footnote(obj):
note = obj.group(1) note = obj.group(1)
supplement["footnote"] += [note] note.replace('\n', ' ')
supplement["footnote"] += ['.. [#] ' + note]
return '[#]_' return '[#]_'
def enum(obj): def enum(obj):
en = obj.group(1) en = obj.group(1)
Expand Down Expand Up @@ -84,9 +86,22 @@ def main():
simple_substitutions = [ simple_substitutions = [
# general substitutions: # general substitutions:
{ {
r"\\textit{(.*)}": r"*\1*", r" +\n": r"\n",
r"\\textbf{(.*)}": r"**\1**", },
r"\\texttt{(.*)}": r"``\1``", {
r"([a-zA-Z0-9,;:\)])\n([a-zA-Z0-9\*])": r"\1 \2",
},
{
r"\\textit{(.*?)}": r"*\1*",
r"\\textbf{(.*?)}": r"**\1**",
r"\\texttt{(.*?)}": r"``\1``",
r"\\url{(.*?)}": r"\1",
r"\A%": r".. ",
r"\n%": r"\n.. ",
r"(\\label{.*?):(.*?})": r"\1_\2",
},
{
r"\\label{(.*?)}": r"`\1`:",
}, },


# custom substitutions (you might add your own here): # custom substitutions (you might add your own here):
Expand All @@ -95,23 +110,25 @@ def main():
r"\\def\\ee\{.*\}": r"", r"\\def\\ee\{.*\}": r"",
}, },
{ {
r"(?<!\\def)\\be(?=[^\w])": r"\\begin{equation}", #r"(?<!\\def)\\be(?=[^\w])": r"\\begin{equation}",
r"(?<!\\def)\\ee(?=[^\w])": r"\\end{equation}", #r"(?<!\\def)\\ee(?=[^\w])": r"\\end{equation}",
r"(?<!\\def)\\ba(?=[^\w])": r"\\begin{array}", #r"(?<!\\def)\\ba(?=[^\w])": r"\\begin{array}",
r"(?<!\\def)\\ea(?=[^\w])": r"\\end{array}", #r"(?<!\\def)\\ea(?=[^\w])": r"\\end{array}",
r"(?ms)\\left\((\\mat{.+?})\\right\)": r"\1", #r"(?ms)\\left\((\\mat{.+?})\\right\)": r"\1",
r"\(\\ref{(.+?)}\)": r":eq:`\1`", #r"\(\\ref{(.+?)}\)": r":eq:`\1`",
r"\\qg":r"|qg|", r"\\qg":r"|qg|",
r"\\nix{(.*)}":r"|nix| \1", r"\\nix{(.*?)}":r"|nix| \1",
r"\\win{(.*)}":r"|win| \1", r"\\win{(.*?)}":r"|win| \1",
r"\\osx{(.*)}":r"|osx| \1", r"\\osx{(.*?)}":r"|osx| \1",
r"(\\cite)":r"FIXME\1", r"(\\cite{(.*?)})":r"[\2]_",
r"\\index{(.*)}":r":index:`\1`", r"\\index{(.*?)}":r":index:`\1`",
r"\\keyboard{(.*?)}":r":kbd:`\1`",
r"\\dialog{(.*?)}":r":guilabel:`\1`",
r"\\toolbtntwo{(.*?)}{(.*?)}":r"|\1| :guilabel:`\2`",
}, },
] ]
filename = args[0] filename = args[0]
s = open(filename).read() s = open(filename).read()
supplement = {"footnote": [], }
# apply the simple substitutions # apply the simple substitutions
for stage in simple_substitutions: for stage in simple_substitutions:
for pattern in stage: for pattern in stage:
Expand All @@ -130,16 +147,17 @@ def main():
s = re.sub(r"(\\end{itemize})", "\n", s) s = re.sub(r"(\\end{itemize})", "\n", s)
s = re.sub(r"(\\begin{enumerate})", "\n", s) s = re.sub(r"(\\begin{enumerate})", "\n", s)
s = re.sub(r"(\\end{enumerate})", "\n", s) s = re.sub(r"(\\end{enumerate})", "\n", s)
s = re.sub(r"\\footnote{(.*)}", footnote, s) s = re.sub(r"(?ms)\\footnote{(.*?)}", footnote, s)
s = re.sub(r"(?ms)\\begin{verbatim}(.+?)\\end{verbatim}", verbatim, s)
# convert titles: # convert titles:
s = re.sub(r"\\chapter{(.+)}", repl_chapter, s) s = re.sub(r"\\chapter{(.+?)}", repl_chapter, s)
s = re.sub(r"\\section\*?{(.+)}", repl_section, s) s = re.sub(r"\\section\*?{(.+?)}", repl_section, s)
s = re.sub(r"\\subsection\*?{(.+)}", repl_subsection, s) s = re.sub(r"\\subsection\*?{(.+?)}", repl_subsection, s)
s = re.sub(r"\\subsubsection\*?{(.+)}", repl_subsubsection, s) s = re.sub(r"\\subsubsection\*?{(.+?)}", repl_subsubsection, s)
s = re.sub(r"\\minisec\*?{(.+)}", repl_minisec, s) s = re.sub(r"\\minisec\*?{(.+?)}", repl_minisec, s)


# add supplement: # add supplement:
s += '\n\n'.join(['\n'.join(supplement[i]) for i in supplement.keys()]) s += '\n\n'.join(['\n '.join(supplement[i]) for i in supplement.keys()])
# either save to a file or dump to stdout: # either save to a file or dump to stdout:
if options.save: if options.save:
outfile = os.path.splitext(filename)[0] + ".rst" outfile = os.path.splitext(filename)[0] + ".rst"
Expand Down
54 changes: 54 additions & 0 deletions readme.rst
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,54 @@
Installation
================================================================================

Very basic steps
--------------------------------------------------------------------------------

* git clone the project
* add the linfiniti-sphinx-theme git repostiory as a submodule
* build the documentation

Installation
--------------------------------------------------------------------------------

Git clone this project.

Create a git submodule support to include the linfiniti-sphinx-theme in your
git project::

git submodule add git@github.com:timlinux/linfiniti-sphinx-theme.git \
linfiniti-sphinx-theme
git submodule
git submodule init linfiniti-sphinx-theme
git submodule update linfiniti-sphinx-theme
git status
git commit -m "Import linfiniti-sphinx-theme as a git submodule" -a
git push
make html

The above being a typical workflow to incorporate the theme as a submodule in
your project.

.. note:: The theme is frozen at the particular version that was current when
you perform the git submodule update command.

If you wish to obtain updates to the theme submodule, the procedure is
something like this::

cd <your sphinx project>/linfiniti-sphinx-theme
git pull
cd ..

Then commit the fact that the submodule now tracks a different SHA1::

git commit -am "Updates linfiniti theme to latest version"
Build the documentation
--------------------------------------------------------------------------------

You can build the html in the following way::

build html
(TODO)

0 comments on commit dc0f7df

Please sign in to comment.