Commit 3ff2e4e3 by Carsten Brandt

improved PDF version of the guide

- better title page, - book style, - improved internal linking using labels and references
parent c51b9956
......@@ -13,6 +13,9 @@ use cebe\markdown\Markdown;
class IndexFileAnalyzer extends Markdown
{
public $title;
public $introduction;
private $_chapter = 0;
private $_chapters = [];
......@@ -25,15 +28,31 @@ class IndexFileAnalyzer extends Markdown
protected function renderHeadline($block)
{
$this->_chapters[++$this->_chapter] = [
if ($this->_chapter === 0) {
$this->title = $block['content'];
$this->introduction = '';
$this->_chapter++;
} else {
$this->_chapter++;
$this->_chapters[$this->_chapter] = [
'headline' => $block['content'],
'content' => [],
];
}
return parent::renderHeadline($block);
}
protected function renderParagraph($block)
{
if ($this->_chapter < 1) {
$this->introduction .= implode("\n", $block['content']);
}
return parent::renderParagraph($block);
}
protected function renderList($block)
{
if ($this->_chapter > 0) {
foreach ($block['items'] as $item => $itemLines) {
if (preg_match('~\[([^\]]+)\]\(([^\)]+)\)(.*)~', implode("\n", $itemLines), $matches)) {
$this->_chapters[$this->_chapter]['content'][] = [
......@@ -43,6 +62,7 @@ class IndexFileAnalyzer extends Markdown
];
}
}
}
return parent::renderList($block);
}
}
\ No newline at end of file
......@@ -69,9 +69,13 @@ class GuideRenderer extends \yii\apidoc\templates\html\GuideRenderer
$output .= '\chapter{' . $chapter['headline'] . "}\n";
foreach($chapter['content'] as $content) {
if (isset($fileData[$content['file']])) {
$md->labelPrefix = $content['file'] . '#';
$output .= '\label{'. $content['file'] . '}';
$output .= $md->parse($fileData[$content['file']]) . "\n\n";
} else {
$output .= '\newpage\textbf{Error: not existing file: '.$content['file'].'}\newpage'."\n";
$output .= '\newpage';
$output .= '\label{'. $content['file'] . '}';
$output .= '\textbf{Error: not existing file: '.$content['file'].'}\newpage'."\n";
}
if ($this->controller !== null) {
......
\documentclass[a4paper, 10pt]{book}
\documentclass[a4paper,11pt,twoside]{book}
% english and utf8
%\usepackage[T1]{fontenc}
......@@ -75,10 +74,79 @@
% http://tex.stackexchange.com/questions/23711/strikethrough-text
\usepackage{ulem}
\newcommand{\centeronpage}{% Horizontal adjustment of image
\ifodd\value{page}\hspace*{\dimexpr\evensidemargin-\oddsidemargin}\else\hspace*{-\dimexpr\evensidemargin-\oddsidemargin}\fi%
}
\title{The definitive Guide to Yii 2.0}
\author{
Qiang Xue,
Alexander Makarov,
Carsten Brandt,
Klimov Paul
and
many contributors from the Yii community
}
%\setlength{\oddsidemargin}{15.5pt}
%\setlength{\evensidemargin}{15.5pt}
% uncomment for debugging layout issues
%\usepackage{showframe}
\begin{document}
\frontmatter
\begin{titlepage}
% ensure centering the title page by ignoring odd and even margin
\setlength{\oddsidemargin}{-1in}
\setlength{\evensidemargin}{-1in}
\setlength{\textwidth}{\paperwidth}
\vspace*{\fill}
% typesetting the title line
\noindent
\parbox{\textwidth}{\centering \bfseries \Huge
The Definitive Guide
}\vspace{.5cm}
\parbox{\textwidth}{\centering \bfseries \Huge
to
}\vspace{.5cm}
\parbox{\textwidth}{\centering \bfseries \Huge
Yii 2.0
}
\vfill
% typesetting authors
\noindent
\parbox{\textwidth}{\centering \Large
Qiang Xue,\\
Alexander Makarov,\\
Carsten Brandt,\\
Klimov Paul\\
and\\
the Yii community
}
\vspace*{\fill}
\noindent
\parbox{\textwidth}{\centering
Copyright 2014 Yii Software LLC.
}
\end{titlepage}
%Take a blank Page
\pagebreak \thispagestyle{empty} \cleardoublepage
\setcounter{tocdepth}{1}
\tableofcontents
\mainmatter
\include{guide}
\end{document}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment