From 3ea972118458d54cea5326b3187916b45f05b629 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 7 Jan 2016 22:25:17 +0100 Subject: [PATCH] Add default doc setup --- doc/.gitignore | 1 + doc/Makefile | 134 ++++++++++++++++++++++++++++ doc/default.nix | 38 ++++++++ doc/src/0000.md | 7 ++ doc/src/pandoc-reference | 170 ++++++++++++++++++++++++++++++++++++ doc/templates/default.html5 | 47 ++++++++++ doc/templates/default.latex | 56 ++++++++++++ 7 files changed, 453 insertions(+) create mode 100644 doc/.gitignore create mode 100644 doc/Makefile create mode 100644 doc/default.nix create mode 100644 doc/src/0000.md create mode 100644 doc/src/pandoc-reference create mode 100644 doc/templates/default.html5 create mode 100644 doc/templates/default.latex diff --git a/doc/.gitignore b/doc/.gitignore new file mode 100644 index 00000000..ba077a40 --- /dev/null +++ b/doc/.gitignore @@ -0,0 +1 @@ +bin diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 00000000..847ff9a5 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,134 @@ +# +# +# +# Variables +# +# +# + +export MAKE_FLAGS=--no-print-directory + +export OUT=$(shell pwd)/bin +export OUT_PDF=$(OUT)/pdf/ +export OUT_HTML=$(OUT)/html/ + +DOCUMENT_CLASS=article +SETTING_FONTSIZE=11pt + +## Source directory +SRC_DIR=$(shell pwd)/src + +## CSS directory +CSS_DIR=$(SRC_DIR)/css + +## All markdown files in the working directory +export SRC=$(shell find $(SRC_DIR) -name "*.md" | sort) + +## Templates +TEMPLATES=$(shell pwd)/templates + +DOCUMENT_SETTINGS_PDF= \ + --listings \ + --variable fontsize=$(SETTING_FONTSIZE) \ + --variable papersize=a4paper \ + --variable classoption=cleardoublepage=empty \ + --variable classoption=index=totoc \ + --variable classoption=openright \ + --variable classoption=final \ + --variable classoption=listof=nochaptergap \ + --variable documentclass=$(DOCUMENT_CLASS) \ + --variable babel-lang=english \ + --variable geometry=portrait + +DOCUMENT_SETTINGS_HTML= \ + --variable lang=de \ + --variable lof=true \ + --variable lol=true \ + --variable lot=true \ + --variable toc=true \ + --table-of-contents \ + --webtex + +# +# +# +# Binary and argument construction +# +# +# + +ECHO_CMD=$(shell which echo) +ECHO_ARG=-e +ECHO=$(ECHO_CMD) $(ECHO_ARG) +export ECHO + +MKDIR_CMD=$(shell which mkdir) +MKDIR_ARG=-p +MKDIR=$(MKDIR_CMD) $(MKDIR_ARG) +export MKDIR + +RM_CMD=$(shell which rm) +RM_ARG=-fr +RM=$(RM_CMD) $(RM_ARG) +export RM + +PANDOC=$(shell which pandoc) + +PANDOC_PARAMS=-r markdown+simple_tables+table_captions+yaml_metadata_block+definition_lists+raw_html+markdown_in_html_blocks + +PANDOC_CC=$(PANDOC) $(PANDOC_PARAMS) + +export PANDOC_CC_PDF=$(PANDOC) \ + $(PANDOC_PARAMS) \ + --latex-engine=pdflatex \ + $(DOCUMENT_SETTINGS_PDF) + +export PANDOC_CC_HTML=$(PANDOC) $(PANDOC_PARAMS) $(DOCUMENT_SETTINGS_HTML) + +TARGET_PDF=$(OUT_PDF)/paper.pdf +TARGET_HTML=$(OUT_HTML)/index.html +# +# +# Tasks +# +# + +# Main task +all: $(TARGET_PDF) $(TARGET_HTML) + @$(ECHO) "\t[ALL ]" + +# create out directory +$(OUT): + @$(ECHO) "\t[MKDIR ] $@" + @$(MKDIR) $(OUT) + +# create html out directory +$(OUT_HTML): $(OUT) + @$(ECHO) "\t[MKDIR ] $@" + @$(MKDIR) $(OUT_HTML) + +# create html out directory +$(OUT_PDF): $(OUT) + @$(ECHO) "\t[MKDIR ] $@" + @$(MKDIR) $(OUT_PDF) + +# cleanup task +clean: + @$(ECHO) "\t[RM ] $@" + @$(RM) $(OUT) + +$(TARGET_PDF): $(OUT_PDF) + @$(ECHO) "\t[PANDOC] pdf" + @$(PANDOC_CC_PDF) \ + --template $(TEMPLATES)/default.latex \ + $(SRC) -o $@ + + +$(TARGET_HTML): $(OUT_HTML) + @$(ECHO) "\t[PANDOC] html" + @$(PANDOC_CC_HTML) \ + --template $(TEMPLATES)/default.html5 \ + $(SRC) -o $@ + +.PHONY: $(TARGET_PDF) $(TARGET_HTML) + diff --git a/doc/default.nix b/doc/default.nix new file mode 100644 index 00000000..8268ab25 --- /dev/null +++ b/doc/default.nix @@ -0,0 +1,38 @@ +{ pkgs ? (import {}) }: + +let + env = with pkgs.haskellPackages; [ + pandoc + + (pkgs.texlive.combine { + inherit (pkgs.texlive) + scheme-small + algorithms + cm-super + collection-basic + collection-fontsextra + collection-fontutils + collection-langenglish + collection-latex + collection-latexextra + collection-latexrecommended + collection-mathextra + collection-pictures + collection-plainextra + collection-science + ; + }) + + pkgs.lmodern + ]; +in + +pkgs.stdenv.mkDerivation rec { + name = "imag-doc"; + src = ./.; + version = "0.0.0"; + + buildInputs = [ env ]; + +} + diff --git a/doc/src/0000.md b/doc/src/0000.md new file mode 100644 index 00000000..308b81f9 --- /dev/null +++ b/doc/src/0000.md @@ -0,0 +1,7 @@ +--- +title: imag Project +version: 0.1 +date: January 2016 +... + + diff --git a/doc/src/pandoc-reference b/doc/src/pandoc-reference new file mode 100644 index 00000000..66e1d94c --- /dev/null +++ b/doc/src/pandoc-reference @@ -0,0 +1,170 @@ + + +# Code examples {#sec:codeexamples} + +In @sec:codeexamples we show some code examples. + +```{#lst:mypython .python .numberLines caption="Python"} +def foo(): + return 1; +``` + +With some Python code in @lst:mypython + + +```{#lst:myruby .ruby .numberLines caption="Ruby"} +def foo + 1 +end +``` + +With some Ruby code in @lst:myruby + + +``` {#lst:myc .c .numberLines caption="C"} +int +foo() { + return 1; +} +``` + +and Some C code in @lst:myc. + + +Aaah, and some `C++`: + +``` {#mycpp .cpp .numberLines caption="C++"} +template +std::tuple mymodule::hassome::foo() +{ + return std::make_tuple(1, 1); +} // I don't even know whether this works +``` + +And, of course, because pandoc: + +~~~~ {#mycode .haskell .numberLines startFrom="100" caption="Haskell"} +qsort [] = [] +qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++ + qsort (filter (>= x) xs) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Table examples + +Pandoc has several extensions for tables, we have them all here: + +## Simple tables + +This is an example for simple tables (@tbl:simple). + + Right Left Center Default +------- ------ ---------- ------- + 12 12 12 12 + 123 123 123 123 + 1 1 1 1 + +Table: Demonstration of simple table syntax. {#tbl:simple} + +------- ------ ---------- ------- + 12 12 12 12 + 123 123 123 123 + 1 1 1 1 +------- ------ ---------- ------- + +And some more go here (in @tbl:more): + +------------------------------------------------------------- + Centered Default Right Left + Header Aligned Aligned Aligned +----------- ------- --------------- ------------------------- + First row 12.0 Example of a row that + spans multiple lines. + + Second row 5.0 Here's another one. Note + the blank line between + rows. +------------------------------------------------------------- + +Table: Here's the caption. It, too, may span +multiple lines. {#tbl:more} + + +## Grid tables + +: Sample grid table. + ++---------------+---------------+--------------------+ +| Fruit | Price | Advantages | ++===============+===============+====================+ +| Bananas | $1.34 | - built-in wrapper | +| | | - bright color | ++---------------+---------------+--------------------+ +| Oranges | $2.10 | - cures scurvy | +| | | - tasty | ++---------------+---------------+--------------------+ + +## Pipe tables + +| Right | Left | Default | Center | +|------:|:-----|---------|:------:| +| 12 | 12 | 12 | 12 | +| 123 | 123 | 123 | 123 | +| 1 | 1 | 1 | 1 | + + : Demonstration of pipe table syntax. + + +# Some maths + +This is simply embedded tex. It renders both in the PDF version +and the HTML version of the output. + +Greek letters are not supported by this setup, though. + + +\begin{equation} +i_{a} = 15 +\end{equation} + +--- + + +$$ \forall x \in X, \quad \exists y \leq \epsilon $$ {#eq:foo} + +In @eq:foo we show something. + +--- + +$$ \frac{n!}{k!(n-k)!} = \binom{n}{k} $$ {#eq:bar} + +--- + +$$ \displaystyle\sum_{i=1}^{10} t_i $$ {#eq:barbar} + +--- + +$$ \sum_{\substack{ + 04\right) $$ {#eq:somethingelse} + +--- + +$$ A_{m,n} = + \begin{pmatrix} + a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\ + a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\ + \vdots & \vdots & \ddots & \vdots \\ + a_{m,1} & a_{m,2} & \cdots & a_{m,n} + \end{pmatrix} $$ {#eq:somethingelseagain} + diff --git a/doc/templates/default.html5 b/doc/templates/default.html5 new file mode 100644 index 00000000..61df31a6 --- /dev/null +++ b/doc/templates/default.html5 @@ -0,0 +1,47 @@ + + + + + + + +$if(date)$ + +$endif$ + + $if(title-prefix)$$title-prefix$ - $endif$$pagetitle$ + + + +$if(highlighting-css)$ + +$endif$ + +$for(css)$ + +$endfor$ + + + + $if(title)$ +
+

$title$

+ $if(date)$ + $date$ + $endif$ + + $if(version)$ + Version: $version$ + $endif$ +
+
+ $endif$ + + $body$ + + + diff --git a/doc/templates/default.latex b/doc/templates/default.latex new file mode 100644 index 00000000..b13af36a --- /dev/null +++ b/doc/templates/default.latex @@ -0,0 +1,56 @@ +\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$} + +\usepackage[sort]{natbib} +\usepackage{fancyhdr} +\usepackage{hyperref} +\usepackage{listings} % source code listings +\usepackage{longtable} % tables +\usepackage{booktabs} % tables +\usepackage{mathtools} +\usepackage{enumitem} + +\providecommand{\tightlist}{ % pandoc wants this + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt} +} + +\oddsidemargin 0.2cm +\topmargin -1.0cm +\textheight 24.0cm +\textwidth 15.25cm +\parindent=0pt +\parskip 1ex +\renewcommand{\baselinestretch}{1.1} +\pagestyle{fancy} + +$if(title)$ + \lhead{\normalsize \textrm{$title$}} +$endif$ + +\chead{} + +$if(version)$ + \lfoot{\normalsize \textrm{$version$}} +$endif$ +\cfoot{} + +$if(date)$ + \rfoot{$date$} +$endif$ + +$for(header-includes)$ + $header-includes$ +$endfor$ + +\setlength{\fboxrule}{4pt}\setlength{\fboxsep}{2ex} +\renewcommand{\headrulewidth}{0.4pt} +\renewcommand{\footrulewidth}{0.4pt} + +\begin{document} + + \begin{center} + {\bf $title$} + \end{center} + + $body$ + +\end{document}