From 9b5801a6e6c80379b79a799a9484cfefb4cebec3 Mon Sep 17 00:00:00 2001 From: Amar Takhar Date: Tue, 19 Jan 2016 00:27:45 -0500 Subject: Add PDF generation support use with --pdf --- book/conf.py | 4 ++ bsp_howto/conf.py | 4 ++ bsp_howto/wscript | 7 +-- c_user/conf.py | 12 +++++ c_user/wscript | 7 +-- common/conf.py | 2 +- common/rtems.sty | 119 ------------------------------------------------- common/rtemsstyle.sty | 119 +++++++++++++++++++++++++++++++++++++++++++++++++ common/waf.py | 63 +++++++++++++++++++------- cpu_supplement/conf.py | 4 ++ cpu_supplement/wscript | 7 +-- develenv/conf.py | 4 ++ develenv/wscript | 7 +-- filesystem/conf.py | 4 ++ filesystem/wscript | 7 +-- networking/conf.py | 4 ++ networking/wscript | 7 +-- porting/conf.py | 4 ++ porting/wscript | 7 +-- posix1003_1/conf.py | 4 ++ posix1003_1/wscript | 7 +-- posix_users/conf.py | 4 ++ posix_users/wscript | 7 +-- rtemsconfig/conf.py | 4 ++ shell/conf.py | 4 ++ shell/wscript | 7 +-- user/conf.py | 4 ++ user/wscript | 7 +-- 28 files changed, 238 insertions(+), 202 deletions(-) create mode 100644 c_user/conf.py delete mode 100644 common/rtems.sty create mode 100644 common/rtemsstyle.sty diff --git a/book/conf.py b/book/conf.py index 5e042a7..4726f1e 100644 --- a/book/conf.py +++ b/book/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'book.tex', u'RTEMS Book', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/bsp_howto/conf.py b/bsp_howto/conf.py index 5e042a7..722d2f5 100644 --- a/bsp_howto/conf.py +++ b/bsp_howto/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'bsp_howto.tex', u'RTEMS BSP Howto Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/bsp_howto/wscript b/bsp_howto/wscript index 0565c4b..8d66b28 100644 --- a/bsp_howto/wscript +++ b/bsp_howto/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) diff --git a/c_user/conf.py b/c_user/conf.py new file mode 100644 index 0000000..7956468 --- /dev/null +++ b/c_user/conf.py @@ -0,0 +1,12 @@ +import sys, os +sys.path.append(os.path.abspath('../common/')) + +from conf import * + +version = '1.0' +release = '5.0' + +latex_documents = [ + ('index', 'c_user.tex', u'RTEMS C User Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/c_user/wscript b/c_user/wscript index 0565c4b..8d66b28 100644 --- a/c_user/wscript +++ b/c_user/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) diff --git a/common/conf.py b/common/conf.py index f50c259..ded57d1 100644 --- a/common/conf.py +++ b/common/conf.py @@ -188,7 +188,7 @@ latex_elements = { latex_use_parts = True -latex_additional_files = ['rtems.sty', 'logo.pdf'] +latex_additional_files = ['../common/rtemsstyle.sty', '../common/logo.pdf'] latex_use_modindex = False diff --git a/common/rtems.sty b/common/rtems.sty deleted file mode 100644 index 5f5e539..0000000 --- a/common/rtems.sty +++ /dev/null @@ -1,119 +0,0 @@ -\definecolor{TitleColor}{rgb}{0,0,0} -\definecolor{InnerLinkColor}{rgb}{0,0,0} -\definecolor{OuterLinkColor}{rgb}{1.0,0.5,0.0} - -\renewcommand{\maketitle}{% - \begin{titlepage}% - \let\footnotesize\small - \let\footnoterule\relax - \ifsphinxpdfoutput - \begingroup - % This \def is required to deal with multi-line authors; it - % changes \\ to ', ' (comma-space), making it pass muster for - % generating document info in the PDF file. - \def\\{, } - \pdfinfo{ - /Author (\@author) - /Title (\@title) - } - \endgroup - \fi - \begin{flushright}% - %\sphinxlogo% - {\center - \vspace*{3cm} - \includegraphics{logo.pdf} - \vspace{3cm} - \par - {\rm\Huge \@title \par}% - {\em\LARGE \py@release\releaseinfo \par} - {\large - \@date \par - \py@authoraddress \par - }}% - \end{flushright}%\par - \@thanks - \end{titlepage}% - \cleardoublepage% - \setcounter{footnote}{0}% - \let\thanks\relax\let\maketitle\relax - %\gdef\@thanks{}\gdef\@author{}\gdef\@title{} -} - -\fancypagestyle{normal}{ - \fancyhf{} - \fancyfoot[LE,RO]{{\thepage}} - \fancyfoot[LO]{{\nouppercase{\rightmark}}} - \fancyfoot[RE]{{\nouppercase{\leftmark}}} - \fancyhead[LE,RO]{{ \@title, \py@release}} - \renewcommand{\headrulewidth}{0.4pt} - \renewcommand{\footrulewidth}{0.4pt} -} - -\fancypagestyle{plain}{ - \fancyhf{} - \fancyfoot[LE,RO]{{\thepage}} - \renewcommand{\headrulewidth}{0pt} - \renewcommand{\footrulewidth}{0.4pt} -} - -\titleformat{\section}{\Large}% - {\py@TitleColor\thesection}{0.5em}{\py@TitleColor}{\py@NormalColor} -\titleformat{\subsection}{\large}% - {\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}{\py@NormalColor} -\titleformat{\subsubsection}{}% - {\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}{\py@NormalColor} -\titleformat{\paragraph}{\large}% - {\py@TitleColor}{0em}{\py@TitleColor}{\py@NormalColor} - -\ChNameVar{\raggedleft\normalsize} -\ChNumVar{\raggedleft \bfseries\Large} -\ChTitleVar{\raggedleft \rm\Huge} - -\renewcommand\thepart{\@Roman\c@part} -\renewcommand\part{% - \pagestyle{plain} - \if@noskipsec \leavevmode \fi - \cleardoublepage - \vspace*{6cm}% - \@afterindentfalse - \secdef\@part\@spart} - -\def\@part[#1]#2{% - \ifnum \c@secnumdepth >\m@ne - \refstepcounter{part}% - \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}% - \else - \addcontentsline{toc}{part}{#1}% - \fi - {\parindent \z@ %\center - \interlinepenalty \@M - \normalfont - \ifnum \c@secnumdepth >\m@ne - \rm\Large \partname~\thepart - \par\nobreak - \fi - \MakeUppercase{\rm\Huge #2}% - \markboth{}{}\par}% - \nobreak - \vskip 8ex - \@afterheading} -\def\@spart#1{% - {\parindent \z@ %\center - \interlinepenalty \@M - \normalfont - \huge \bfseries #1\par}% - \nobreak - \vskip 3ex - \@afterheading} - -% use inconsolata font -\usepackage{inconsolata} - -% fix single quotes, for inconsolata. (does not work) -%%\usepackage{textcomp} -%%\begingroup -%% \catcode`'=\active -%% \g@addto@macro\@noligs{\let'\textsinglequote} -%% \endgroup -%%\endinput diff --git a/common/rtemsstyle.sty b/common/rtemsstyle.sty new file mode 100644 index 0000000..5f5e539 --- /dev/null +++ b/common/rtemsstyle.sty @@ -0,0 +1,119 @@ +\definecolor{TitleColor}{rgb}{0,0,0} +\definecolor{InnerLinkColor}{rgb}{0,0,0} +\definecolor{OuterLinkColor}{rgb}{1.0,0.5,0.0} + +\renewcommand{\maketitle}{% + \begin{titlepage}% + \let\footnotesize\small + \let\footnoterule\relax + \ifsphinxpdfoutput + \begingroup + % This \def is required to deal with multi-line authors; it + % changes \\ to ', ' (comma-space), making it pass muster for + % generating document info in the PDF file. + \def\\{, } + \pdfinfo{ + /Author (\@author) + /Title (\@title) + } + \endgroup + \fi + \begin{flushright}% + %\sphinxlogo% + {\center + \vspace*{3cm} + \includegraphics{logo.pdf} + \vspace{3cm} + \par + {\rm\Huge \@title \par}% + {\em\LARGE \py@release\releaseinfo \par} + {\large + \@date \par + \py@authoraddress \par + }}% + \end{flushright}%\par + \@thanks + \end{titlepage}% + \cleardoublepage% + \setcounter{footnote}{0}% + \let\thanks\relax\let\maketitle\relax + %\gdef\@thanks{}\gdef\@author{}\gdef\@title{} +} + +\fancypagestyle{normal}{ + \fancyhf{} + \fancyfoot[LE,RO]{{\thepage}} + \fancyfoot[LO]{{\nouppercase{\rightmark}}} + \fancyfoot[RE]{{\nouppercase{\leftmark}}} + \fancyhead[LE,RO]{{ \@title, \py@release}} + \renewcommand{\headrulewidth}{0.4pt} + \renewcommand{\footrulewidth}{0.4pt} +} + +\fancypagestyle{plain}{ + \fancyhf{} + \fancyfoot[LE,RO]{{\thepage}} + \renewcommand{\headrulewidth}{0pt} + \renewcommand{\footrulewidth}{0.4pt} +} + +\titleformat{\section}{\Large}% + {\py@TitleColor\thesection}{0.5em}{\py@TitleColor}{\py@NormalColor} +\titleformat{\subsection}{\large}% + {\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}{\py@NormalColor} +\titleformat{\subsubsection}{}% + {\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}{\py@NormalColor} +\titleformat{\paragraph}{\large}% + {\py@TitleColor}{0em}{\py@TitleColor}{\py@NormalColor} + +\ChNameVar{\raggedleft\normalsize} +\ChNumVar{\raggedleft \bfseries\Large} +\ChTitleVar{\raggedleft \rm\Huge} + +\renewcommand\thepart{\@Roman\c@part} +\renewcommand\part{% + \pagestyle{plain} + \if@noskipsec \leavevmode \fi + \cleardoublepage + \vspace*{6cm}% + \@afterindentfalse + \secdef\@part\@spart} + +\def\@part[#1]#2{% + \ifnum \c@secnumdepth >\m@ne + \refstepcounter{part}% + \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}% + \else + \addcontentsline{toc}{part}{#1}% + \fi + {\parindent \z@ %\center + \interlinepenalty \@M + \normalfont + \ifnum \c@secnumdepth >\m@ne + \rm\Large \partname~\thepart + \par\nobreak + \fi + \MakeUppercase{\rm\Huge #2}% + \markboth{}{}\par}% + \nobreak + \vskip 8ex + \@afterheading} +\def\@spart#1{% + {\parindent \z@ %\center + \interlinepenalty \@M + \normalfont + \huge \bfseries #1\par}% + \nobreak + \vskip 3ex + \@afterheading} + +% use inconsolata font +\usepackage{inconsolata} + +% fix single quotes, for inconsolata. (does not work) +%%\usepackage{textcomp} +%%\begingroup +%% \catcode`'=\active +%% \g@addto@macro\@noligs{\let'\textsinglequote} +%% \endgroup +%%\endinput diff --git a/common/waf.py b/common/waf.py index 88c5690..55c7517 100644 --- a/common/waf.py +++ b/common/waf.py @@ -33,33 +33,64 @@ class spell(BuildContext): def cmd_configure(ctx): - ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD") + ctx.load('tex') + + if not ctx.env.PDFLATEX: + conf.fatal('The program LaTex is required') + + ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD", mandatory=True) +# ctx.find_program("pdflatex", var="BIN_PDFLATEX", mandatory=True) ctx.find_program("aspell", var="BIN_ASPELL", mandatory=False) + def cmd_build(ctx, conf_dir=".", source_dir="."): srcnode = ctx.srcnode.abspath() - # Copy resources. - for dir in ["_static", "_templates"]: - files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir) - ctx.path.get_bld().make_node(dir).mkdir() # dirs + if ctx.options.pdf: ctx( - features = "subst", - is_copy = True, - source = files, - target = [ctx.bldnode.find_node(dir).get_bld().make_node(x.name) for x in files] + rule = "${BIN_SPHINX_BUILD} -b latex -c %s -j %d -d build/doctrees %s build/latex" % (conf_dir, ctx.options.jobs, source_dir), + cwd = ctx.path.abspath(), + source = ctx.path.ant_glob('**/*.rst'), + target = "latex/%s.tex" % ctx.path.name ) - ctx( - rule = "${BIN_SPHINX_BUILD} -b html -c %s -j %d -d build/doctrees %s build/html" % (conf_dir, ctx.options.jobs, source_dir), - cwd = ctx.path.abspath(), - source = ctx.path.ant_glob('**/*.rst'),# + ctx.path.ant_glob('conf.py'), - target = ctx.path.find_or_declare('html/index.html') - ) + ctx.add_group() + + ctx( + features = 'tex', + cwd = "%s/latex/" % ctx.path.get_bld().abspath(), + type = 'pdflatex', + source = ctx.bldnode.find_or_declare("latex/%s.tex" % ctx.path.name), + prompt = 0 + ) + + else: + # Copy HTML resources. + for dir in ["_static", "_templates"]: + files = ctx.path.parent.find_node("common").ant_glob("%s/*" % dir) + ctx.path.get_bld().make_node(dir).mkdir() # dirs + + ctx( + features = "subst", + is_copy = True, + source = files, + target = [ctx.bldnode.find_node(dir).get_bld().make_node(x.name) for x in files] + ) + + ctx( + rule = "${BIN_SPHINX_BUILD} -b html -c %s -j %d -d build/doctrees %s build/html" % (conf_dir, ctx.options.jobs, source_dir), + cwd = ctx.path.abspath(), + source = ctx.path.ant_glob('**/*.rst'),# + ctx.path.ant_glob('conf.py'), + target = ctx.path.find_or_declare('html/index.html') + ) + +def cmd_options(ctx): + ctx.add_option('--pdf', action='store_true', default=False, help="Build PDF.") def cmd_options_path(ctx): - ctx.add_option('--rtems-path-py', type='string', help="Path to py/ in RTEMS.") + cmd_options(ctx) + ctx.add_option('--rtems-path-py', type='string', help="Full path to py/ in RTEMS source repository.") def cmd_configure_path(ctx): diff --git a/cpu_supplement/conf.py b/cpu_supplement/conf.py index 5e042a7..3c9c2f7 100644 --- a/cpu_supplement/conf.py +++ b/cpu_supplement/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'cpu_supplement.tex', u'RTEMS CPU Supplement Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/cpu_supplement/wscript b/cpu_supplement/wscript index 0565c4b..8d66b28 100644 --- a/cpu_supplement/wscript +++ b/cpu_supplement/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) diff --git a/develenv/conf.py b/develenv/conf.py index 5e042a7..d6bc2bd 100644 --- a/develenv/conf.py +++ b/develenv/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'develenv.tex', u'RTEMS Development Environment Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/develenv/wscript b/develenv/wscript index 0565c4b..8d66b28 100644 --- a/develenv/wscript +++ b/develenv/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) diff --git a/filesystem/conf.py b/filesystem/conf.py index 5e042a7..2018730 100644 --- a/filesystem/conf.py +++ b/filesystem/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'filesystem.tex', u'RTEMS Filesystem Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/filesystem/wscript b/filesystem/wscript index 0565c4b..8d66b28 100644 --- a/filesystem/wscript +++ b/filesystem/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) diff --git a/networking/conf.py b/networking/conf.py index 5e042a7..cc244c2 100644 --- a/networking/conf.py +++ b/networking/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'networking.tex', u'RTEMS Networking Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/networking/wscript b/networking/wscript index 0565c4b..8d66b28 100644 --- a/networking/wscript +++ b/networking/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) diff --git a/porting/conf.py b/porting/conf.py index 5e042a7..8ccb18f 100644 --- a/porting/conf.py +++ b/porting/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'porting.tex', u'RTEMS Porting Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/porting/wscript b/porting/wscript index 0565c4b..8d66b28 100644 --- a/porting/wscript +++ b/porting/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) diff --git a/posix1003_1/conf.py b/posix1003_1/conf.py index 5e042a7..7e33ef5 100644 --- a/posix1003_1/conf.py +++ b/posix1003_1/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'posix1003_1.tex', u'RTEMS POSIX 1003_1 Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/posix1003_1/wscript b/posix1003_1/wscript index 0565c4b..8d66b28 100644 --- a/posix1003_1/wscript +++ b/posix1003_1/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) diff --git a/posix_users/conf.py b/posix_users/conf.py index 5e042a7..fcbb017 100644 --- a/posix_users/conf.py +++ b/posix_users/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'posix_users.tex', u'RTEMS POSIX Users Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/posix_users/wscript b/posix_users/wscript index 0565c4b..8d66b28 100644 --- a/posix_users/wscript +++ b/posix_users/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) diff --git a/rtemsconfig/conf.py b/rtemsconfig/conf.py index 5e042a7..d9e87bb 100644 --- a/rtemsconfig/conf.py +++ b/rtemsconfig/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'rtemsconfig.tex', u'RTEMS RTEMS Config Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/shell/conf.py b/shell/conf.py index 5e042a7..7ee08cf 100644 --- a/shell/conf.py +++ b/shell/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'shell.tex', u'RTEMS Shell Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/shell/wscript b/shell/wscript index 0565c4b..8d66b28 100644 --- a/shell/wscript +++ b/shell/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) diff --git a/user/conf.py b/user/conf.py index 5e042a7..bf58783 100644 --- a/user/conf.py +++ b/user/conf.py @@ -6,3 +6,7 @@ from conf import * version = '1.0' release = '5.0' +latex_documents = [ + ('index', 'user.tex', u'RTEMS User Documentation', u'RTEMS Documentation Project', 'manual'), +] + diff --git a/user/wscript b/user/wscript index 0565c4b..8d66b28 100644 --- a/user/wscript +++ b/user/wscript @@ -2,10 +2,5 @@ from sys import path from os.path import abspath path.append(abspath('../common/')) -from waf import cmd_configure, cmd_build, spell, cmd_spell +from waf import cmd_configure as configure, cmd_build as build, spell, cmd_spell, cmd_options as options -def configure(ctx): - cmd_configure(ctx) - -def build(ctx): - cmd_build(ctx) -- cgit v1.2.3