Skip to content

Commit

Permalink
Merge pull request #123 from JuliaGNI/make_mac_docs
Browse files Browse the repository at this point in the history
Simplified Makefile and created tests for latex docs on ubuntu and macos.
  • Loading branch information
michakraus authored Mar 21, 2024
2 parents dd04caf + 92b4b03 commit f28974d
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 65 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/Latex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: PDF

on:
push:
branches:
- main
pull_request:

jobs:
LatexDocs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- if: matrix.os == 'ubuntu-latest'
name: install imagemagick and poppler-utils
run: |
sudo apt-get install imagemagick
sudo apt-get install poppler-utils
- if: matrix.os == 'macos-latest'
run: |
pip3 install Pygments
- name: install texlive
run: |
wget --no-check-certificate https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
zcat < install-tl-unx.tar.gz | tar xf -
rm install-tl-unx.tar.gz
cd install-tl-*
sudo perl ./install-tl --no-interaction
cd ..
- name: add texlive to path
if: matrix.os == 'ubuntu-latest'
run: |
echo "/usr/local/texlive/2024/bin/x86_64-linux" >> $GITHUB_PATH
- name: add texlive to path
if: matrix.os == 'macos-latest'
run: |
echo "/usr/local/texlive/2024/bin/universal-darwin" >> $GITHUB_PATH
- name: Make images
if: matrix.os == 'ubuntu-latest'
run: |
make linux -C docs/src/tikz
- name: Make images
if: matrix.os == 'macos-latest'
run: |
make mac -C docs/src/tikz
- uses: julia-actions/setup-julia@latest
with:
version: '1'
- name: install BrenierTwoFluid
run: |
cd docs
make install_brenier_two_fluid test_docs
cd ..
- name: make tex document
run: julia --project=docs --threads=2 docs/make.jl latex_output_no_pdf
- name: compile tex document
run: |
cd docs/build
xelatex -shell-escape GeometricMachineLearning.jl.tex
- name: Upload PDF file
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: docs/build/GeometricMachineLearning.jl.pdf
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 23 additions & 6 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

all: html

latex: images install_brenier_two_fluid test_docs latex_docs remove_brenier_two_fluid
latex_mac: images_mac install_brenier_two_fluid test_docs latex_docs remove_brenier_two_fluid

html: images install_brenier_two_fluid test_docs documenter remove_brenier_two_fluid
latex_linux: images_linux install_brenier_two_fluid test_docs latex_docs remove_brenier_two_fluid

latex_linux_no_pdf: images_linux install_brenier_two_fluid test_docs latex_docs_no_pdf remove_brenier_two_fluid

latex_mac_no_pdf: images_mac install_brenier_two_fluid test_docs latex_docs_no_pdf remove_brenier_two_fluid

html: html_images install_brenier_two_fluid test_docs documenter remove_brenier_two_fluid

test_docs:
cd ..; julia --project=docs -e '; \
Expand All @@ -31,13 +37,24 @@ remove_brenier_two_fluid:
documenter:
julia --color=yes --project=. --threads=8 make.jl html_output

images:
$(MAKE) all -C src/tikz
html_images:
$(MAKE) pdf -C src/tikz ;
$(MAKE) png res1=150 res2=200 res3=100 res4=180 -C src/tikz ;
$(MAKE) logo -C src/tikz ;
$(MAKE) clean -C src/tikz

images_mac:
$(MAKE) mac -C src/tikz

images_linux:
$(MAKE) linux -C src/tikz

clean:
$(MAKE) empty -C src/tikz
$(MAKE) empty -C src/tikz ;
rm -Rf build

latex_docs:
julia --color=yes --project=. --threads=8 make.jl latex_output


latex_docs_no_pdf:
julia --color=yes --project=. --threads=8 make.jl latex_output_no_pdf
8 changes: 6 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ const html_format = Documenter.HTML(;

const latex_format = Documenter.LaTeX()

const output_type = isempty(ARGS) ? :html : ARGS[1] == "latex_output" ? :latex : :html
# if platform is set to "none" then no output pdf is generated
const latex_format_no_pdf = Documenter.LaTeX(platform = "none")

const format = output_type == :latex ? latex_format : html_format
# if we supply no arguments to make.jl or supply html_output, then `output_type` is `:html`. Else it is latex.
const output_type = isempty(ARGS) ? :html : ARGS[1] == "html_output" ? :html : :latex

const format = output_type == :html ? html_format : ARGS[1] == "latex_output" ? latex_format : latex_format_no_pdf

makedocs(;
plugins = [bib],
Expand Down
93 changes: 93 additions & 0 deletions docs/src/assets/custom.sty
Original file line number Diff line number Diff line change
@@ -1 +1,94 @@
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}

% colours
\usepackage{xcolor}

\definecolor{light-blue}{HTML}{6b85dd}
\definecolor{dark-blue}{HTML}{4266d5}
\definecolor{light-red}{HTML}{d66661}
\definecolor{dark-red}{HTML}{c93d39}
\definecolor{light-green}{HTML}{6bab5b}
\definecolor{dark-green}{HTML}{3b972e}
\definecolor{light-purple}{HTML}{aa7dc0}
\definecolor{dark-purple}{HTML}{945bb0}
\definecolor{codeblock-background}{gray}{0.96}
\definecolor{codeblock-border}{gray}{0.8}
%

% maths
\usepackage{amsmath, amssymb}
%

% listings
\usepackage{minted}
\setminted{
breaklines = true,
fontsize = \small,
frame = none,
bgcolor = codeblock-background,
rulecolor=codeblock-border,
}
%

% tables
\usepackage{tabulary}
%

% hyperref
\usepackage{hyperref}
\hypersetup{
pdfpagelabels,
bookmarks,
hyperindex,
unicode = true,
linkcolor = dark-blue,
urlcolor = dark-purple,
colorlinks = true,
}
%

% table of contents
\maxtocdepth{subsection}
%

% paragraphs
\setlength{\parindent}{0pt}
\nonzeroparskip
%

% adjust margins
\setulmarginsandblock{1.5in}{1in}{*}
\setlrmarginsandblock{1.5in}{1in}{*}
\setheaderspaces{1in}{*}{*}
\checkandfixthelayout
%

% images etc.
\usepackage{graphicx}
\usepackage[export]{adjustbox}
%

% Some internal link targets are implemented with \label, some with \hypertarget,
% but they require different links. This inserts a \hyperref if a corresponding label exists,
% and \hyperlink if it doesn't.
\def\hyperlinkref#1#2{\@ifundefined{r@#1}{\hyperlink{#1}{#2}}{\hyperref[#1]{#2}}}
%

% styling of admonitions. tcolorbox is available in the texlive-latex-extra
% package
\usepackage{tcolorbox}
% These colors are taken from documenter-light.css in the HTML assets.
\definecolor{admonition-default}{HTML}{363636}
\definecolor{admonition-danger}{HTML}{da0b00}
\definecolor{admonition-warning}{HTML}{ffdd57}
\definecolor{admonition-note}{HTML}{209cee}
\definecolor{admonition-info}{HTML}{209cee}
\definecolor{admonition-tip}{HTML}{22c35b}
\definecolor{admonition-compat}{HTML}{1db5c9}
%

% Styling of tables.
\usepackage{booktabs}
%
\usepackage{arydshln}
45 changes: 45 additions & 0 deletions docs/src/assets/preamble.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
%% Default preamble BEGIN
\documentclass[oneside]{memoir}

\usepackage{./custom}

%% Title Page
\title{
{\HUGE \DocMainTitle }\\
{\Large \DocVersion }
}
\author{ \DocAuthors }

%% TOC settings
% -- TOC depth
% value: [part, chapter, section, subsection,
% subsubsection, paragraph, subparagraph]
\settocdepth{section} % show "part+chapter+section" in TOC
% -- TOC spacing
% ref: https://tex.stackexchange.com/questions/60317/toc-spacing-in-memoir
% doc: memoir/memman.pdf
% - Figure 9.2: Layout of a ToC
% - Table 9.3: Value of K in macros for styling entries
\makeatletter
% {part} to {chapter}
\setlength{\cftbeforepartskip}{1.5em \@plus \p@}
% {chapter} to {chapter}
\setlength{\cftbeforechapterskip}{0.0em \@plus \p@}
% Chapter num to chapter title spacing (Figure 9.2@memman)
\setlength{\cftchapternumwidth}{2.5em \@plus \p@}
% indent before section number
\setlength{\cftsectionindent}{2.5em \@plus \p@}
% Section num to section title spacing (Figure 9.2@memman)
\setlength{\cftsectionnumwidth}{4.0em \@plus \p@}
\makeatother

%% Main document begin
\begin{document}

\frontmatter
\maketitle
\clearpage
\tableofcontents

\mainmatter
%% preamble END
Loading

0 comments on commit f28974d

Please sign in to comment.