Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaTeX publisher #545

Merged
merged 88 commits into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
1699644
Added .tex file ending support.
Feb 15, 2022
ff0f564
Added --latex flag.
Feb 15, 2022
650d9fa
Added function for LaTeX attribute, i.e., links.
Feb 15, 2022
99edefb
Added new function by pure copy from Markdown.
Feb 15, 2022
563fff6
Added call to new _lines_latex function.
Feb 15, 2022
11a1c2a
Updated function doc.
Feb 15, 2022
be25b26
Fixed headings.
Feb 15, 2022
fff17ed
Fixed body levels.
Feb 15, 2022
a39cd4f
Fixed attribute call to correct function.
Feb 15, 2022
e2b652d
Fixed smaller headings.
Feb 15, 2022
bd15163
Fixed external references.
Feb 15, 2022
da889e5
Fixed links.
Feb 15, 2022
f7f3ed9
Fixed custom attributes.
Feb 15, 2022
f8eb702
Fixed ** formatting.
Feb 15, 2022
5d1bffd
Corrected bold and italics.
Feb 15, 2022
772d06a
Changed > to be a quote.
Feb 15, 2022
8cce51b
Fixed $ characters.
Feb 15, 2022
7644b70
Fixed end of attribute table.
Feb 15, 2022
410a799
Fixed manual headings.
Feb 15, 2022
6236a21
Fixed strikethrough
Feb 15, 2022
383b28d
Fixed tables in running text.
Feb 15, 2022
06745f2
Fixed code blocks.
Feb 15, 2022
81e20af
Fixed plantUML
Feb 15, 2022
4203bef
Fixed MATH which required a re-structuring to two functions.
Feb 15, 2022
4f818d1
Corrected the publishing of levels.
Feb 16, 2022
e5bde5d
Fixed links to be active between documents.
Feb 16, 2022
7bdfbc7
Added doorstop.cls to allow proper typesetting.
Feb 16, 2022
f814aef
Added automated wrapper generation with cross-references between docu…
Feb 16, 2022
dcc341c
Fixed filenames for single file publish.
Feb 16, 2022
1b4e46d
Fixed warning message.
Feb 16, 2022
6055b19
Removed red color from lastpage number in footer.
Feb 16, 2022
3479576
Changed color in TOC.
Feb 16, 2022
0e4fb7f
Fixed extra \\ to actually make new paragraphs.
Feb 16, 2022
701ad5b
Fixed enumeration.
Feb 16, 2022
8c6bb14
Fixed itemize and corner cases when ending a file with a list.
Feb 16, 2022
48b203e
Re-structured EOF detection.
Feb 16, 2022
fd9ea4d
Syntax fixed by running make ci.
Feb 16, 2022
0c7c2a9
Syntax fix.
Feb 16, 2022
f56d6b0
Syntax fix.
Feb 16, 2022
77c2870
Restructured for less complexity.
Feb 16, 2022
1879f17
Linting changes.
Feb 16, 2022
955b95d
Fixed all internal links to use the same color.
Feb 17, 2022
2e4ced5
Added traceability matrix to LaTeX output.
Feb 17, 2022
a6f0378
Added try block to handle mocked tests.
Feb 17, 2022
078a187
Added test file for publisher_latex.py
Feb 17, 2022
88dc843
Added test without LaTeX doc data in .doorstop.yml
Feb 17, 2022
d3fddcc
Added test to publish LaTeX in tree form.
Feb 17, 2022
66e0505
Added test for complete publish.
Feb 18, 2022
306ace2
Added test for not publishing heading levels.
Feb 18, 2022
6a5cc2d
Restructured tests.
Feb 18, 2022
e384f03
Added test of settings change and added a helper function.
Feb 28, 2022
4bbafdb
Added helper function to convert returned generator to string.
Feb 28, 2022
87d2911
Added test of single to test settings.PUBLISH_HEADING_LEVELS
Feb 28, 2022
a8345ba
Restructured test to reduce file sizes and added complete test for PU…
Feb 28, 2022
cd955e2
Added test of settings.ENABLE_HEADERS
Feb 28, 2022
8faca68
Added test of settings.PUBLISH_BODY_LEVELS
Feb 28, 2022
a0a4838
Added test of settings.PUBLISH_CHILD_LINKS
Feb 28, 2022
8f746d6
Added test of settings.CHECK_REF for new and old reference styles.
Mar 1, 2022
64a2a7a
Removed extra `
Mar 1, 2022
8e5dbe8
Added extra custom attribute to get higher coverage.
Mar 1, 2022
e47ae45
Restructured tests to match other test suite files.
Mar 1, 2022
8dbe920
Cleaned up.
Mar 1, 2022
0449bf8
Added test of custom attributes.
Mar 1, 2022
315c096
Added tests for math environment.
Mar 1, 2022
e04354a
Fixed bug found in math environment.
Mar 1, 2022
05061fc
Cleaned up.
Mar 1, 2022
387a479
Added tests of the enumeration environement.
Mar 1, 2022
7a24a93
Added tests of the itemize environment.
Mar 1, 2022
b6413ca
Added tests of table environment.
Mar 1, 2022
4b6700a
Added warnings when bad tables are found.
Mar 1, 2022
f5bb830
Added sorting to folder walk since OSX and linux sorts differently.
neerdoc Mar 2, 2022
5667dfe
Completed warning checks.
neerdoc Mar 2, 2022
ba655cf
Added test of plantUML generation.
Mar 2, 2022
3f75d99
Added error if plantUML title is missing.
Mar 2, 2022
fd30958
Added tests for missing endings of environments and blocks.
Mar 2, 2022
bf7f972
Fixed wrong ending of plantUML environment.
Mar 2, 2022
ba83078
Updated documentation with LaTeX information.
Mar 2, 2022
fafd6d0
Fixed typos.
Mar 2, 2022
82d433d
Fixed more typos.
Mar 2, 2022
d48e93f
Fixed typos correctly this time.
Mar 2, 2022
28b158e
--latex flag not needed on individual documents.
Mar 2, 2022
27bea40
Added test of typesetting images, with and without title.
Mar 2, 2022
b2143e6
Added typesetting of images.
Mar 2, 2022
c2d7d4f
Added test that assets for the LaTeX-class are published for single d…
Mar 2, 2022
e252e90
Added link to logo.
Mar 2, 2022
c80f17b
Removed traceability matrix when publishing a single document.
Mar 2, 2022
a92461d
Moved compile_path generation to inside LaTex case.
Mar 2, 2022
761d056
Made test more robust since order differs between operating systems.
Mar 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions docs/cli/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,40 @@ The collection of documents can be published as a webpage:
$ doorstop publish all ./dist/
```

# LaTeX

Individual documents or the collection of all documents can be published as a LaTeX-format file that then can be typeset by running ```pdflatex``` on the exported files. To ensure easy compilation of a complete collection with cross-references and generated plantUML diagrams, a ```compile.sh```-file is automatically created in the export folder.

## Example individual document
```
$ doorstop publish TUT path/to/name_here_is_ignored.tex
building tree...
publishing document TUT to '<...>/path/to/name_here_is_ignored.tex'...
WARNING: LaTeX export does not support custom file names. Change in .doorstop.yml instead.
You can now execute the file 'compile.sh' twice in the exported folder to produce the PDFs!
published: <...>/path/to/name_here_is_ignored.tex
$ cd path/to/
$ . ./compile.sh
This is pdfTeX, Version <Lots of text cut out!>
$ . ./compile.sh
This is pdfTeX, Version <Lots of text cut out!>
```

## Example collection of documents
```
$ doorstop publish --latex all path/to/
building tree...
loading documents...
publishing tree to '<...>/path/to'...
You can now execute the file 'compile.sh' twice in the exported folder to produce the PDFs!
published: <...>/path/to
$ cd path/to/
$ . ./compile.sh
This is pdfTeX, Version <Lots of text cut out!>
$ . ./compile.sh
This is pdfTeX, Version <Lots of text cut out!>
```

# Additional formats

Or a file can be created using one of the supported extensions:
Expand All @@ -28,3 +62,4 @@ Supported formats:
- Text: `.txt`
- Markdown: `.md`
- HTML: `.html`
- LaTeX: `.tex`
1 change: 1 addition & 0 deletions doorstop/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ def _publish(subs, shared):
"-t", "--text", action="store_true", help="output text (default when no path)"
)
group.add_argument("-m", "--markdown", action="store_true", help="output Markdown")
group.add_argument("-l", "--latex", action="store_true", help="output LaTeX")
group.add_argument(
"-H", "--html", action="store_true", help="output HTML (default for 'all')"
)
Expand Down
1 change: 1 addition & 0 deletions doorstop/cli/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def get_ext(args, error, ext_stdout, ext_file, whole_tree=False):
".yml": "yaml",
".csv": "csv",
".xlsx": "xlsx",
".tex": "latex",
}.items():
try:
if getattr(args, option):
Expand Down
287 changes: 287 additions & 0 deletions doorstop/core/files/assets/latex/doorstop.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LaTeX document class: doorstop.cls
%%
%% Derived from the Standard LaTeX Book article class.
%%
%% This document class is free to use, copy, distribute,
%% and modify, as long as reference to the original author
%% is given.
%%
%% Original author: Gustav Johansson, gustav@neer.se
%%
%% Last modified by: Gustav Johansson, February 16, 2022.
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ******************************************************
% Identification
% ******************************************************
\def\classversion{1.0}
\def\classdate{Feb 16, 2022}

\typeout{Document class version: \classversion}
\typeout{Last modified: \classdate}
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{doorstop}

% ******************************************************
% Declare Options
% ******************************************************
% Do not know how to handle other options and therefore
% just pass them on to 'article'
\DeclareOption{proofing}{\def\proof{1}}
% Make sure we can do bold typewriter
\DeclareFontShape{OT1}{cmtt}{bx}{n}{<5><6><7><8><9><10><10.95><12><14.4><17.28><20.74><24.88>cmttb10}{}
% Setup the hyperref package options
\PassOptionsToPackage{bookmarks=true,%
bookmarksopen=true,%
pdfborder={0 0 0},%
pdfhighlight={/N},%
linkbordercolor={.5 .5 .5},%
raiselinks=true,%
nesting=false}{hyperref}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

% ******************************************************
% Process Options
% ******************************************************
\ProcessOptions*

% ******************************************************
% Improve error finding capabilities
% ******************************************************
\errorcontextlines 10000

% ******************************************************
% Load Used Packages and Classes
% ******************************************************
\LoadClass{article}
\RequirePackage{titletoc}
\RequirePackage{palatino}
\RequirePackage{graphicx}
\RequirePackage{fancyhdr}
\RequirePackage{multirow}
\RequirePackage{lastpage}
\RequirePackage{color}
\RequirePackage{listings}
\RequirePackage{tikz}
\RequirePackage{xstring}
\RequirePackage{titlesec}
\RequirePackage{appendix}
% The following packages are REQUIRED to make the Doorstop publish functions work.
\RequirePackage{amsmath}
\RequirePackage{ulem}
\RequirePackage{longtable}
\RequirePackage{fancyvrb}
\RequirePackage{xr-hyper}
\RequirePackage[unicode,colorlinks]{hyperref}
\RequirePackage{zref-user}
\RequirePackage{zref-xr}

% ******************************************************
% Functions for PlantUML support.
% ******************************************************
% Define an verbatim environment for PlantUML:
\newenvironment{plantuml}[1]{\VerbatimOut{#1.txt}}{\endVerbatimOut}

% Process a PlantUML code:
\newcommand{\process}[3]{%
% Call PlantUML to produce a svg vector graphcis:
\immediate\write18{plantuml -tsvg #1.txt}
% Call Inkscape to convert the svg to a pdf (pdflatex cannot use svg):
\immediate\write18{inkscape #1.svg --export-pdf=#1.pdf}
% Include the pdf:
\begin{figure}[h]
\includegraphics[width=#2]{#1.pdf}
\caption{#3}
\end{figure}
% Remove all intermediate files:
\immediate\write18{rm #1.txt #1.svg #1.pdf}
}

% ******************************************************
% Start defining and redefining old article style stuff
% ******************************************************
% Setup the page margins
\setlength{\topmargin}{-2cm}
\setlength{\textwidth}{16cm}
\setlength{\textheight}{23cm}
\setlength{\evensidemargin}{-4.5mm}
\setlength{\oddsidemargin}{5.5mm}
\setlength{\intextsep}{24pt}
\setlength{\headheight}{3cm}
\setlength{\headwidth}{16cm}

% Define logotype and trim.
\newcommand{\definetrim}[2]{%
\define@key{Gin}{#1}[]{\setkeys{Gin}{trim=#2,clip}}%
}
\def\logo{assets/logo-black-white.png}
\definetrim{logotrim}{0 100px 0 100px}

% Define a copyright claimer.
\def\owner{Doorstop}
\def\claimer{\color{black!40}All information in this document is the intellectual property of \owner{}. You are not allowed to disclose any information herein to a third party prior to written consent from \owner{}. All rights reserved. \copyright \owner{}}

% Sets the counting depths for TOC
\setcounter{tocdepth}{4}
\setcounter{topnumber}{5}
\setcounter{totalnumber}{6}

% Change paragraph to act as a subsubsubsection
\setcounter{secnumdepth}{4}
\titleformat{\paragraph}[hang]{\normalfont\normalsize\bfseries}{\theparagraph}{1em}{}
\titlespacing*{\paragraph}{0pt}{3.25ex plus 1ex minus .2ex}{1em}

% Setup colors
\definecolor{grey}{rgb}{0.75,0.75,0.75}
\definecolor{orchid}{rgb}{0.8516,0.4375,0.8359}

% Set internal link color
\hypersetup{linkcolor=orchid}

% Setup how the TOC looks
% Section
\titlecontents*{section}[1.5em]
{\scshape\bfseries}
{\thecontentslabel\hspace*{1pc}}
{}
{\normalfont\titlerule*[1pc]{.}\contentspage\\[1mm]}
% Subsection
\titlecontents*{subsection}[2em]
{\normalfont\scshape}
{\thecontentslabel\hspace*{1pc}}
{}
{\titlerule*[1pc]{.}\contentspage\\[0.6mm]}
% Subsubsection
\titlecontents*{subsubsection}[2em]
{\normalfont}
{\thecontentslabel\hspace*{1pc}}
{}
{\titlerule*[1pc]{.}\contentspage\\[0.3mm]}
% Paragraph (subsubsubsection)
\titlecontents*{paragraph}[2em]
{\normalfont}
{\thecontentslabel\hspace*{1pc}\itshape}
{}
{\normalfont\titlerule*[1pc]{.}\contentspage\\[0.3mm]}

% Setup the listings package
\lstset{breaklines=true,basicstyle=\ttfamily,moredelim=[is][\bfseries]{€}{€}}

% Setup how the headings look
% Section
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\scshape\Large\bfseries}}
% Subsection
\renewcommand\subsection{\@startsection {subsection}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\scshape\large\bfseries}}

% Setup how floats are placed on the pages
\renewcommand{\topfraction}{.95}
\renewcommand{\textfraction}{.05}
\renewcommand{\floatpagefraction}{.75}

% Setup the headers and footers
% Fancy style
\pagestyle{fancy}
\fancyhf{}% Clear all settings
\fancyhead[RE,RO]{\raisebox{0.5cm}{\textsf{\begin{tabular}{p{6.5cm}p{2.8cm}p{0.7cm}}
\textbf{\large\docname} & {\footnotesize Ref} &{\footnotesize By}\tabularnewline
\multirow{3}{7cm}[1ex]{\doccategory}&\textrm{\small\docref} & \textrm{\small\docby} \tabularnewline
&{\footnotesize Date} & {\footnotesize Issue}\tabularnewline
&\textrm{\small\today} & \textrm{\small\docissuemajor\docissueminor} \tabularnewline
\end{tabular}}}}
\fancyhead[LE,LO]{\hspace*{0.2cm}\includegraphics[logotrim, width=4.5cm]{\logo}}
\fancyfoot[RO]{%
\thepage(\pageref*{LastPage})
\begin{tikzpicture}[overlay,remember picture]
\node [rotate=-90, font=\tiny, yshift=-0.6cm, text width=9cm] at (current page.east)
{\claimer
};
\end{tikzpicture}
}
\fancyfoot[LE]{%
\thepage(\pageref*{LastPage})
\begin{tikzpicture}[overlay,remember picture]
\node [rotate=90, font=\tiny, yshift=-0.6cm, text width=9cm] at (current page.west)
{\claimer
};
\end{tikzpicture}
}
% Blankpage style
\fancypagestyle{blankpage}{ %
\fancyhf{}% Clear all settings
\renewcommand{\headrulewidth}{0pt} % remove lines as well
\renewcommand{\footrulewidth}{0pt}
\fancyfoot[RO]{%
\thepage(\pageref*{LastPage})
\begin{tikzpicture}[overlay,remember picture]
\node [rotate=-90, font=\tiny, yshift=-0.6cm, text width=9cm] at (current page.east)
{\claimer
};
\end{tikzpicture}
}
\fancyfoot[LE]{%
\thepage(\pageref*{LastPage})
\begin{tikzpicture}[overlay,remember picture]
\node [rotate=90, font=\tiny, yshift=-0.6cm, text width=9cm] at (current page.west)
{\claimer
};
\end{tikzpicture}
}
\vspace*{10cm}
\Huge{\color{grey}This page was intentionally left blank.}
\vspace*{\fill}
}

% ******************************************************
% Make it easy to use appendices
% ******************************************************
\newcommand{\app}{%
\appendix%
\clearpage{\thispagestyle{blankpage}\cleardoublepage}%
}

% ******************************************************
% Generate cover page/toc etc.
% ******************************************************

\newcommand{\makecoverpage}{
\pagestyle{empty}
\thispagestyle{empty}
%--- Make title page
\setcounter{page}{1}
\begin{center}
\includegraphics[logotrim, width=6.5cm]{\logo}\\[1mm]
\vspace{0.5cm} \mbox{}\hrulefill \mbox{}\\[1.5cm]
{\Huge \textbf{\textsc{\doctitle\\[2cm]}}}
{\LARGE \textbf{\docname}}\\[15mm]
{\large \doccategory} \vfill
{\large \mbox{}\hrulefill\mbox{}\\[50mm]}
\end{center}
\clearpage{\thispagestyle{blankpage}\cleardoublepage}
\pagestyle{fancy}
}
%--- Make TOC
\newcommand{\maketoc}{
\pagestyle{fancy}
\thispagestyle{fancy}
\tableofcontents
\clearpage{\thispagestyle{blankpage}\cleardoublepage}
\pagestyle{fancy}
}


% ******************************************************
% Define a ToDo-command.
% ******************************************************
\newcommand{\todo}[1]{%
\noindent\textcolor{red}{\textbf{TODO:} #1}
}
1 change: 1 addition & 0 deletions doorstop/core/files/assets/latex/logo-black-white.png
Loading