Skip to content
Browse files

ZFDocumentor: some corrections and begin the PDF version

  • Loading branch information...
1 parent a927c6d commit be125adb521de0d7891aca73c0a110aa11ef0a64 @mikaelkael committed Dec 20, 2011
View
33 Makefile.in
@@ -49,9 +49,9 @@ ZF_LANG=en
ZF_VERSION=1.11
# "make" or "make -e"
-all: $(MANUAL_XML) htmlhelp
+all: html
-$(MANUAL_XML): ../standard/branches/release-$(ZF_VERSION)/documentation/manual/en/$(MANUAL_XML).in rev-svn
+$(MANUAL_XML): ../standard/branches/release-$(ZF_VERSION)/documentation/manual/en/$(MANUAL_XML).in rev-svn version-zf
@echo "Creating temporary manual and preprocessing it..."
@rm -Rf ./temp/files/
@rm -Rf ./temp/en/
@@ -83,6 +83,11 @@ $(MANUAL_XML): ../standard/branches/release-$(ZF_VERSION)/documentation/manual/e
@php -f tools/ManualXML.php $(ZF_VERSION)
@rm -Rf ./temp/files/
+test:
+ @[ -d temp ] || mkdir temp
+ echo $(ZF_LANG) | tr [:lower:] [:upper:] > temp/lang
+ echo "toto" > temp/`cat temp/lang`
+
docbook-migration: $(MANUAL_XML)
$(XSLTPROC) --xinclude ./tools/db4-upgrade.xsl ./temp/manual.xml > ./temp/manual-db5.xml
@@ -94,20 +99,19 @@ figures:
rev-svn:
@[ -d temp ] || mkdir temp
@export LANG=en_US.UTF8
- @svn info ../standard/branches/release-$(ZF_VERSION)/documentation/manual/$(ZF_LANG) | grep '^Last Changed Rev' | sed -e 's!Last Changed Rev: !!m' -e 's!(\n)!!' > ./temp/svn_rev \
+ @svn info ../standard/branches/release-$(ZF_VERSION)/documentation/manual/$(ZF_LANG) | grep '^Last Changed Rev' | sed -e 's!Last Changed Rev: !!m' | tr -d '\n'> ./temp/svn_rev \
|| @echo "Impossible to read svn revision"
+version-zf:
+ @[ -d temp ] || mkdir temp
+ @php -r "include_once '../standard/branches/release-$(ZF_VERSION)/library/Zend/Version.php'; echo Zend_Version::VERSION;" > ./temp/zf_version
+
# Build the docs in HTML format
website: html zipdoc
html: docbook-migration figures
- @if [ -d output/website/$(ZF_VERSION)/$(ZF_LANG)/ ] ; then \
- echo "Rendering already done" ; \
- else \
- rm -Rf output/website/$(ZF_VERSION)/$(ZF_LANG)/ ; \
- echo "Rendering the whole manual as html..." ; \
- ./phd --xinclude --forceindex -f xhtml -P Mkk -o output/website/$(ZF_VERSION)/$(ZF_LANG) -d ./temp/manual-db5.xml ; \
- fi
+ @rm -Rf output/website/$(ZF_VERSION)/$(ZF_LANG)/
+ @./phd --xinclude --forceindex -f xhtml -P Mkk -L $(ZF_LANG) -o output/website/$(ZF_VERSION)/$(ZF_LANG) -d ./temp/manual-db5.xml
@[ -f output/website/$(ZF_VERSION)/$(ZF_LANG)/index.sqlite ] && rm output/website/$(ZF_VERSION)/$(ZF_LANG)/index.sqlite
@[ -d output/website/images ] || mkdir output/website/images
@[ -d output/website/scripts ] || mkdir output/website/scripts
@@ -125,7 +129,6 @@ zipdoc:
@mkdir temp/zfdoc/scripts
@mkdir temp/zfdoc/styles
@cp -R output/website/$(ZF_VERSION)/$(ZF_LANG)/* temp/zfdoc
- @[ -f temp/zfdoc/index.sqlite ] && rm temp/zfdoc/index.sqlite
@cp -R output/website/figures/*.* temp/zfdoc/figures
@cp -f images/*.* temp/zfdoc/images
@cp -f styles/*.* temp/zfdoc/styles
@@ -135,15 +138,14 @@ zipdoc:
@echo '.editions{display:none;}' >> temp/zfdoc/styles/zfdocumentor.css
@echo '#searchZf{display:none;}' >> temp/zfdoc/styles/zfdocumentor.css
@echo '#header{height:60px;}' >> temp/zfdoc/styles/zfdocumentor.css
- @(cd temp ; zip -q -r ../docs/Zend_Framework_$(ZF_VERSION).x_$(ZF_LANG).zip zfdoc)
+ @(cd temp ; zip -q -r ../docs/Zend_Framework_$(ZF_VERSION).x_`echo $(ZF_LANG) | tr [:lower:] [:upper:]`.zip zfdoc)
lucene:
@php -f tools/IndexLucene.php $(ZF_VERSION) $(ZF_LANG)
htmlhelp: docbook-migration figures
@rm -Rf output/htmlhelp/$(ZF_VERSION)/$(ZF_LANG)/
- @echo "Rendering the whole manual as htmlhelp..."
- ./phd --xinclude --forceindex -f chm -P Mkk -o output/htmlhelp/$(ZF_VERSION)/$(ZF_LANG) -d ./temp/manual-db5.xml
+ @./phd --xinclude --forceindex -f chm -P Mkk -L $(ZF_LANG) -o output/htmlhelp/$(ZF_VERSION)/$(ZF_LANG) -d ./temp/manual-db5.xml
@cp -f figures/*.* output/htmlhelp/$(ZF_VERSION)/$(ZF_LANG)/res
@cp -f images/*.* output/htmlhelp/$(ZF_VERSION)/$(ZF_LANG)/res
@cp -f styles/*.* output/htmlhelp/$(ZF_VERSION)/$(ZF_LANG)/res
@@ -163,7 +165,7 @@ chm: htmlhelp
# Build the docs in PDF format
pdf: docbook-migration figures
@rm -Rf output/pdf/$(ZF_VERSION)/$(ZF_LANG)/
- ./phd --xinclude --forceindex -f chm -P Mkk -o output/pdf/$(ZF_VERSION)/$(ZF_LANG) -d ./temp/manual-db5.xml
+ @./phd --xinclude --forceindex -g 'phpdotnet\phd\Highlighter_GeSHi' -f pdf -P Mkk -L $(ZF_LANG) -o output/pdf/$(ZF_VERSION)/$(ZF_LANG) -d ./temp/manual-db5.xml
# checking manual
check: $(MANUAL_XML)
@@ -193,6 +195,7 @@ clean:
cleanall: clean
-rm -Rf ./output
-rm -Rf ./figures
+ -rm -Rf ./docs
-rm -f config.* configure
-rm -rf autom4te.cache
-rm -f Makefile
View
3 generate-doc.sh
@@ -18,7 +18,10 @@
#
date
export LANG=en_US.UTF8
+export LANGUAGE=en_US.UTF8
echo Cleaning
+autoconf
+./configure
make clean
make -e website ZF_LANG=en ZF_VERSION=1.11
make -e website ZF_LANG=de ZF_VERSION=1.11
View
1 generate-lucene.sh
@@ -18,6 +18,7 @@
#
date
export LANG=en_US.UTF8
+export LANGUAGE=en_US.UTF8
echo Cleaning
make -e lucene ZF_LANG=en ZF_VERSION=1.11
make -e lucene ZF_LANG=de ZF_VERSION=1.11
View
0 searchLanguage.sh 100644 → 100755
File mode changed.
View
4 tools/IndexLucene.php
@@ -41,9 +41,9 @@ public static function makeSearchIndexAction($version = '1.11', $lang = 'en')
$index->addDocument($doc);
}
}
- echo ' - optimisation...';
+ echo ' - optimisation...' . PHP_EOL;
$index->optimize();
- echo "Index is created and optimized.";
+ echo "Index is created and optimized." . PHP_EOL;
}
/**
View
14 tools/phpdotnet/phd/Format/Abstract/PDF.php
@@ -4,7 +4,7 @@
abstract class Format_Abstract_PDF extends Format {
protected $pdfDoc;
-
+
public function getPdfDoc() {
return $this->pdfDoc;
}
@@ -46,6 +46,8 @@ class PdfWriter {
const FONT_VERBATIM = 0x04;
const FONT_VERBATIM_ITALIC = 0x05;
const FONT_MANUAL = 0x06;
+ const FONT_VERBATIM_BOLD = 0x07;
+ const FONT_VERBATIM_BOLDITALIC = 0x08;
// "Objects" constants (for add())
const PARA = 0x10;
@@ -151,7 +153,9 @@ function __construct($pageWidth = 210, $pageHeight = 297) {
$this->fonts["Helvetica-Bold"] = $this->haruDoc->getFont("Helvetica-Bold", "WinAnsiEncoding");
$this->fonts["Helvetica-Oblique"] = $this->haruDoc->getFont("Helvetica-Oblique", "WinAnsiEncoding");
$this->fonts["Courier"] = $this->haruDoc->getFont("Courier", "WinAnsiEncoding");
+ $this->fonts["Courier-Bold"] = $this->haruDoc->getFont("Courier-Bold", "WinAnsiEncoding");
$this->fonts["Courier-Oblique"] = $this->haruDoc->getFont("Courier-Oblique", "WinAnsiEncoding");
+ $this->fonts["Courier-BoldOblique"] = $this->haruDoc->getFont("Courier-BoldOblique", "WinAnsiEncoding");
// Add first page and default font settings
$this->currentFont = $this->fonts["Helvetica"];
@@ -454,10 +458,18 @@ public function setFont($type, $size = null, $color = null, $font = null) {
$this->currentPage->setFontAndSize($this->currentFont = $this->fonts["Courier"],
$this->currentFontSize);
break;
+ case self::FONT_VERBATIM_BOLD:
+ $this->currentPage->setFontAndSize($this->currentFont = $this->fonts["Courier-Bold"],
+ $this->currentFontSize);
+ break;
case self::FONT_VERBATIM_ITALIC:
$this->currentPage->setFontAndSize($this->currentFont = $this->fonts["Courier-Oblique"],
$this->currentFontSize);
break;
+ case self::FONT_VERBATIM_BOLDITALIC:
+ $this->currentPage->setFontAndSize($this->currentFont = $this->fonts["Courier-BoldOblique"],
+ $this->currentFontSize);
+ break;
case self::FONT_MANUAL:
$this->currentPage->setFontAndSize($this->currentFont = $font, $this->currentFontSize);
break;
View
4 tools/phpdotnet/phd/Package/Generic/PDF.php
@@ -299,7 +299,7 @@
public function __construct() {
parent::__construct();
$this->setExt(Config::ext() === null ? ".pdf" : Config::ext());
- $this->pdfDoc = new PdfWriter();
+ $this->pdfDoc = new PdfWriter();
}
public function __destruct() {
@@ -510,7 +510,7 @@ public function format_verbatim_block($open, $name, $attrs, $props) {
public function format_verbatim_inline($open, $name, $attrs, $props) {
if ($open) {
- $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM, 10);
+ $this->pdfDoc->setFont(PdfWriter::FONT_VERBATIM, 12);
} else {
$this->pdfDoc->revertFont();
}
View
2 tools/phpdotnet/phd/Package/Mkk/CHM.php
@@ -332,7 +332,7 @@ protected function headerChm() {
fwrite($this->hhpStream, '[OPTIONS]
Binary TOC=Yes
Compatibility=1.1 or later
-Compiled file=zf.chm
+Compiled file=../../Zend_Framework_' . $this->minorZf . '.x_' . strtoupper($this->lang) . '.chm
Contents file=zf.hhc
Default Font=' . ($this->LANGUAGES[$lang]["preferred_font"] ? $this->LANGUAGES[$lang]["preferred_font"] : self::DEFAULT_FONT). '
Default topic=res' . DIRECTORY_SEPARATOR . 'manual.html
View
20 tools/phpdotnet/phd/Package/Mkk/ChunkedXHTML.php
@@ -4,9 +4,9 @@
class Package_Mkk_ChunkedXHTML extends Package_Generic_ChunkedXHTML
{
- private $minorZf = '1.11';
- private $revisionZf = '1.11.11';
- private $revisionSvn = 24783;
+ protected $minorZf = null;
+ protected $revisionZf = null;
+ protected $revisionSvn = null;
private $myelementmap = array();
private $replaceElementMap = array(
@@ -41,6 +41,10 @@ class Package_Mkk_ChunkedXHTML extends Package_Generic_ChunkedXHTML
public function __construct()
{
+ // Read ZF version
+ $this->revisionSvn = file_get_contents('temp/svn_rev');
+ $this->revisionZf = file_get_contents('temp/zf_version');
+ $this->minorZf = implode('.', array_slice(explode('.', $this->revisionZf), 0, 2));
parent::__construct();
$this->zfOutputDir = Config::output_dir();
$this->registerFormatName("Mkk-Chunked-XHTML");
@@ -79,10 +83,10 @@ public function format_programlisting($open, $name, $attrs)
$tag = '<pre class="programlisting';
if (isset($attrs[Reader::XMLNS_DOCBOOK]["language"])) {
$this->role = $attrs[Reader::XMLNS_DOCBOOK]["language"];
- $tag .= ' brush: ' . $this->role;
} else {
- $this->role = false;
+ $this->role = 'php';
}
+ $tag .= ' brush: ' . $this->role;
$tag .= '">';
return $tag;
@@ -166,9 +170,9 @@ public function header($id)
</form>
<div id="alternateDoc" style="position: absolute;top: 10px; right:10px;">
- <a href="/docs/Zend_Framework_{shortVersion}.x_{lang}.zip"><img src="/images/zip.png" alt="Downloadable version of this documentation" title="Downloadable version of this documentation" /></a>
- <a style="{alternateDoc}" href="/docs/Zend_Framework_{shortVersion}.x_{LANG}.pdf"><img src="/images/pdf.png" alt="PDF version of this documentation" title="PDF version of this documentation" /></a>
- <a style="{alternateDoc}" href="/docs/Zend_Framework_{shortVersion}.x_{LANG}.chm"><img src="/images/chm.png" alt="CHM version of this documentation" title="CHM version of this documentation" /></a>
+ <a href="/docs/Zend_Framework_' . $this->revisionZf . '.x_' . strtoupper($this->lang) . '.zip"><img src="/images/zip.png" alt="Downloadable version of this documentation" title="Downloadable version of this documentation" /></a>
+ <a style="{alternateDoc}" href="/docs/Zend_Framework_' . $this->revisionZf . '.x_' . strtoupper($this->lang) . '.pdf"><img src="/images/pdf.png" alt="PDF version of this documentation" title="PDF version of this documentation" /></a>
+ <a style="{alternateDoc}" href="/docs/Zend_Framework_' . $this->revisionZf . '.x_' . strtoupper($this->lang) . '.chm"><img src="/images/chm.png" alt="CHM version of this documentation" title="CHM version of this documentation" /></a>
</div>
<ul class="editions">
View
105 tools/phpdotnet/phd/Package/Mkk/PDF.php
@@ -14,7 +14,8 @@ class Package_Mkk_PDF extends Package_Generic_PDF
'part' => 'format_tocnode_newpage',
),
'callout' => 'format_collect_id',
- 'chapter' => 'format_tocnode_newpage',
+ 'chapter' => 'format_tocnode_newpage',
+ 'classname' => 'format_verbatim_inline',
'co' => 'format_collect_id',
'colophon' => 'format_tocnode_newpage',
'footnote' => 'format_collect_id',
@@ -24,12 +25,14 @@ class Package_Mkk_PDF extends Package_Generic_PDF
'book' => 'format_tocnode_newpage',
'part' => 'format_tocnode_newpage',
),
+ 'important' => 'format_admonition',
'index' => array(
/* DEFAULT */ 'format_suppressed_tags',
'article' => 'format_tocnode_newpage',
'book' => 'format_tocnode_newpage',
'part' => 'format_tocnode_newpage',
),
+ 'interface' => 'format_verbatim_inline',
'legalnotice' => 'format_tocnode_newpage',
'part' => 'format_tocnode_newpage',
'phpdoc:exceptionref' => 'format_tocnode_exception',
@@ -38,12 +41,6 @@ class Package_Mkk_PDF extends Package_Generic_PDF
'refentry' => 'format_tocnode_newpage',
'reference' => 'format_tocnode_newpage',
'phpdoc:varentry' => 'format_tocnode_newpage',
- 'sect1' => 'format_tocnode',
- 'sect2' => 'format_tocnode',
- 'sect3' => 'format_tocnode',
- 'sect4' => 'format_tocnode',
- 'sect5' => 'format_tocnode',
- 'section' => 'format_tocnode',
'set' => array(
/* DEFAULT */ 'format_root_set',
'set' => 'format_set',
@@ -80,6 +77,8 @@ class Package_Mkk_PDF extends Package_Generic_PDF
);
+ protected $role = false;
+
private $acronyms = array();
/* Common properties for all functions pages */
@@ -120,7 +119,7 @@ public function update($event, $val = null) {
case Render::INIT:
if (!class_exists("HaruDoc")) die ("PDF output needs libharu & haru/pecl extensions... Please install them and start PhD again.\n");
- $this->setOutputDir(Config::output_dir() . strtolower($this->getFormatName()) . DIRECTORY_SEPARATOR);
+ $this->setOutputDir(Config::output_dir());
if(!file_exists($this->getOutputDir()) || is_file($this->getOutputDir())) mkdir($this->getOutputDir()) or die("Can't create the cache directory.\n");
break;
case Render::VERBOSE:
@@ -166,7 +165,7 @@ public function format_book($open, $name, $attrs, $props) {
$this->resolveLinks($this->cchunk["bookname"]);
$pdfDoc = parent::getPdfDoc();
v("Writing PDF Manual (%s)", $this->cchunk["bookname"], VERBOSE_TOC_WRITING);
- $pdfDoc->saveToFile($this->getOutputDir() . $this->toValidName($this->cchunk["bookname"]) . "." . $this->getExt());
+ $pdfDoc->saveToFile($this->getOutputDir() . '../../Zend_Framework_' . $this->minorZf . '.x_' . strtoupper($this->lang) . $this->getExt());
unset($pdfDoc);
}
return false;
@@ -319,4 +318,92 @@ public function format_collect_id($open, $name, $attrs, $props, $newpage = false
}
return false;
}
+
+ public function format_verbatim_block($open, $name, $attrs, $props) {
+ if ($open) {
+ $this->cchunk["verbatim-block"] = true;
+ $this->pdfDoc->add(PdfWriter::VERBATIM_BLOCK);
+ if (isset($attrs[Reader::XMLNS_DOCBOOK]["language"])) {
+ $this->role = $attrs[Reader::XMLNS_DOCBOOK]["language"];
+ } else {
+ $this->role = false;
+ }
+ } else {
+ $this->pdfDoc->add(PdfWriter::LINE_JUMP);
+ $this->pdfDoc->revertFont();
+ $this->cchunk["verbatim-block"] = false;
+ $this->role = false;
+ }
+ return "";
+ }
+
+ public function TEXT($str) {
+ static $i = 0;
+ if (isset($this->cchunk["refsection"]) && $this->cchunk["refsection"]) // DUMMY REFSECTION DELETION
+ return "";
+
+ if (isset($this->cchunk["verbatim-block"]) && $this->cchunk["verbatim-block"]) {
+ //$str = $this->highlight(trim($str), $this->role, 'xhtml');
+ $language = array_search($this->role, array('sh' => 'shell',
+ 'ini' => 'dosini',
+ 'js' => 'javascript'));
+ $language = $language ? $language : $this->role;
+ exec('echo "' . str_replace(array('"', '$'), array('\"', '\$'), $str) . "\" | highlight --inline-css -f --syntax $language", $highlight);
+ $highlight = array_slice($highlight, 1, count($highlight) - 2);
+ foreach ($highlight as $line) {
+ $line = str_replace(array('&gt;', '&lt;', '&quot;'), array('>', '<', '"'), $line);
+ while (strpos($line, '<span') !== false) {
+ $pos = strpos($line, '<span');
+ if ($pos == 0) {
+ $last = strpos($line, '</span>') + 7;
+ $text = substr($line, 0, $last);
+ preg_match('#<span style="(.*)">(.*)</span>#', $text, $matches);
+ $styles = explode(';', $matches[1]);
+ $format = array();
+ foreach ($styles as $s) {
+ $f = explode(':', $s);
+ $format[trim($f[0])] = trim($f[1]);
+ }
+ if (isset($format['color'])) {
+ $colors = array(hexdec(substr($format['color'], 1, 2)) / 255,
+ hexdec(substr($format['color'], 3, 2)) / 255,
+ hexdec(substr($format['color'], 5, 2)) / 255);
+ } else {
+ $colors = array(0, 0, 0);
+ }
+ $font = PdfWriter::FONT_VERBATIM;
+ if (isset($format['font-weight']) && isset($format['font-style'])) {
+ $font = PdfWriter::FONT_VERBATIM_BOLDITALIC;
+ } else {
+ if (isset($format['font-weight'])) {
+ $font = PdfWriter::FONT_VERBATIM_BOLD;
+ }
+ if (isset($format['font-style'])) {
+ $font = PdfWriter::FONT_VERBATIM_ITALIC;
+ }
+ }
+ $this->pdfDoc->setFont($font, null, $colors);
+ $this->pdfDoc->appendText(utf8_decode($matches[2]));
+ $this->pdfDoc->revertFont();
+ $line = substr($line, $last);
+ } else {
+ $this->pdfDoc->appendText(utf8_decode(substr($line, 0, $pos)));
+ $line = substr($line, $pos);
+ }
+ }
+ if (strlen($line)) {
+ $this->pdfDoc->appendText(utf8_decode($line));
+ }
+ $this->pdfDoc->add(PdfWriter::PARA);
+ }
+ return "";
+ }
+
+ $ret = utf8_decode(trim(preg_replace('/[ \n\t]+/', ' ', $str)));
+ // No whitespace if current text value begins with ',', ';', ':', '.'
+ if (strncmp($ret, ",", 1) && strncmp($ret, ";", 1) && strncmp($ret, ":", 1) && strncmp($ret, ".", 1))
+ $this->pdfDoc->appendText(" " . $ret);
+ else $this->pdfDoc->appendText($ret);
+ return "";
+ }
}

0 comments on commit be125ad

Please sign in to comment.
Something went wrong with that request. Please try again.