svn: /phpdoc/doc-base/branches/docgen-update/scripts/docgen/ docgen.php structures/Docgen_Job.php structures/jobtypes/Docgen_ExtensionJob.php
| From: | Justin Martin | Date: | Wed, 22 Feb 2012 23:42:18 +0000 |
| Subject: | svn: /phpdoc/doc-base/branches/docgen-update/scripts/docgen/ docgen.php structures/Docgen_Job.php structures/jobtypes/Docgen_ExtensionJob.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-9649@lists.php.net to get a copy of this message | ||
frozenfire Wed, 22 Feb 2012 23:42:18 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=323439
Log:
Switched to using XMLWriter instead. Not as pretty, but DOM doesn't format when using entities.
Changed paths:
U phpdoc/doc-base/branches/docgen-update/scripts/docgen/docgen.php
U phpdoc/doc-base/branches/docgen-update/scripts/docgen/structures/Docgen_Job.php
U
phpdoc/doc-base/branches/docgen-update/scripts/docgen/structures/jobtypes/Docgen_ExtensionJob.php
Modified: phpdoc/doc-base/branches/docgen-update/scripts/docgen/docgen.php
===================================================================
--- phpdoc/doc-base/branches/docgen-update/scripts/docgen/docgen.php 2012-02-22 22:40:46 UTC (rev
323438)
+++ phpdoc/doc-base/branches/docgen-update/scripts/docgen/docgen.php 2012-02-22 23:42:18 UTC (rev
323439)
@@ -3,7 +3,7 @@
// Required extensions
if(!extension_loaded("reflection")) trigger_error("Docgen requires the Reflection
extension", E_USER_ERROR);
if(!extension_loaded("pcre")) trigger_error("Docgen requires the PCRE
extension", E_USER_ERROR);
-if(!extension_loaded("dom")) trigger_error("Docgen requires the DOM extension",
E_USER_ERROR);
+if(!extension_loaded("xmlwriter")) trigger_error("Docgen requires the DOM
extension", E_USER_ERROR);
// Required includes
require_once(__DIR__."/structures/Docgen_JobManager.php");
Modified: phpdoc/doc-base/branches/docgen-update/scripts/docgen/structures/Docgen_Job.php
===================================================================
--- phpdoc/doc-base/branches/docgen-update/scripts/docgen/structures/Docgen_Job.php 2012-02-22
22:40:46 UTC (rev 323438)
+++ phpdoc/doc-base/branches/docgen-update/scripts/docgen/structures/Docgen_Job.php 2012-02-22
23:42:18 UTC (rev 323439)
@@ -18,22 +18,16 @@
return preg_replace(array('/[^[:alnum:]]/', '/^-+/'),
array('-', ''), strtolower($name));
}
- protected static function newline(DOMNode &$parent, DOMDocument &$document) {
- $nl = $document->createDocumentFragment();
- $nl->appendXML("\n");
- $parent->appendChild($nl);
- }
-
- protected function addExamples(DOMNode &$parent, DOMDocument &$document) {
+ protected function addExamples() {
}
- protected function addSeeAlso(DOMNode &$parent, DOMDocument &$document) {
+ protected function addSeeAlso() {
}
- protected function addLocalVariables(DOMNode &$parent, DOMDocument &$document) {
- $parent->appendChild($document->createComment(
+ protected function addLocalVariables(XMLWriter $writer) {
+ $writer->writeComment(
' Keep this comment at the end of the file
24 Local variables:
25 mode: sgml
@@ -54,6 +48,6 @@
40 vim: et tw=78 syn=sgml
41 vi: ts=1 sw=1
'
- ));
+ );
}
}
Modified:
phpdoc/doc-base/branches/docgen-update/scripts/docgen/structures/jobtypes/Docgen_ExtensionJob.php
===================================================================
---
phpdoc/doc-base/branches/docgen-update/scripts/docgen/structures/jobtypes/Docgen_ExtensionJob.php 2012-02-22
22:40:46 UTC (rev 323438)
+++
phpdoc/doc-base/branches/docgen-update/scripts/docgen/structures/jobtypes/Docgen_ExtensionJob.php 2012-02-22
23:42:18 UTC (rev 323439)
@@ -12,33 +12,43 @@
public function createBook() {
$extensionID = self::format_identifier($this->reflection->name);
- $bookDocument = new DOMDocument("1.0", "utf-8");
- $bookDocument->appendChild($bookDocument->createComment('$Revision$'));
+ $writer = new XMLWriter;
+ $writer->openMemory();
+ $writer->setIndent(true);
+ $writer->setIndentString(" ");
+ $writer->startDocument("1.0", "UTF-8");
+ $writer->writeComment(' $Revision$ ');
- $book = $bookDocument->createElement("book");
- $book->setAttribute("xml:id", "book.{$extensionID}");
- $book->setAttribute("xmlns", "http://docbook.org/ns/docbook");
- $book->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
- $bookDocument->appendChild($book);
+ $writer->startElement("book");
+ $writer->writeAttribute("xml:id", "book.extname");
+ $writer->writeAttribute("xmlns", "http://docbook.org/ns/docbook");
+ $writer->writeAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
- $book->appendChild($bookDocument->createElement("title",
$this->reflection->name));
- $book->appendChild($bookDocument->createElement("titleabbrev",
$this->reflection->name."..."));
+ $writer->writeElement("title", $this->reflection->name);
+ $writer->writeElement("titleabbrev",
$this->reflection->name."...");
+
+ $writer->writeRaw("\n");
+
+ $writer->writeComment(" {{{ preface ");
+ $writer->startElement("preface");
+ $writer->writeRaw("\n &reftitle.intro;\n");
+ $writer->writeElement("para", "Extension introduction.");
+ $writer->endElement();
+ $writer->writeComment(" }}} ");
+
+ $writer->writeRaw("\n");
+
+ $writer->writeRaw(" &reference.{$extensionID}.setup;\n");
+ $writer->writeRaw(" &reference.{$extensionID}.constants;\n");
+ $writer->writeRaw(" &reference.{$extensionID}.reference;\n");
+
+ $writer->writeRaw("\n");
+
+ $writer->endElement();
+ $writer->endDocument();
+
+ $this->addLocalVariables($writer);
- $book->appendChild($bookDocument->createComment(" {{{ preface "));
- $preface = $bookDocument->createElement("preface");
- $preface->setAttribute("xml:id", "intro.{$extensionID}");
- $book->appendChild($preface);
-
-
$preface->appendChild($bookDocument->createEntityReference("reftitle.intro"));
- $preface->appendChild($bookDocument->createElement("para",
"Extension introduction."));
- $book->appendChild($bookDocument->createComment(" }}} "));
-
-
$book->appendChild($bookDocument->createEntityReference("reference.{$extensionID}.setup"));
-
$book->appendChild($bookDocument->createEntityReference("reference.{$extensionID}.constants"));
-
$book->appendChild($bookDocument->createEntityReference("reference.{$extensionID}.reference"));
-
- $this->addLocalVariables($bookDocument, $bookDocument);
-
- $this->documents["reference/{$extensionID}/book.xml"] = $bookDocument;
+ $this->documents["reference/{$extensionID}/book.xml"] = $writer->flush();
}
}