31 $xmlRootNode = new \SimpleXMLElement(
'<?xml version="1.0" encoding="UTF-8"?> 32 <section version="5.0" xmlns="http://docbook.org/ns/docbook" 33 xml:id="fluid.usermanual.standardviewhelpers" 34 xmlns:xl="http://www.w3.org/1999/xlink" 35 xmlns:xi="http://www.w3.org/2001/XInclude" 36 xmlns:xhtml="http://www.w3.org/1999/xhtml" 37 xmlns:svg="http://www.w3.org/2000/svg" 38 xmlns:ns="http://docbook.org/ns/docbook" 39 xmlns:mathml="http://www.w3.org/1998/Math/MathML"> 40 <title>Standard View Helper Library</title> 42 <para>Should be autogenerated from the tags.</para> 44 foreach ($classNames as $className) {
47 return $xmlRootNode->asXML();
59 $reflectionClass = new \TYPO3\CMS\Extbase\Reflection\ClassReflection($className);
60 if (!$reflectionClass->isSubclassOf($this->abstractViewHelperReflectionClass)) {
64 $docbookSection = $xmlRootNode->addChild(
'section');
65 $docbookSection->addChild(
'title', $tagName);
66 $this->docCommentParser->parseDocComment($reflectionClass->getDocComment());
67 $this->
addDocumentation($this->docCommentParser->getDescription(), $docbookSection);
68 $argumentsSection = $docbookSection->addChild(
'section');
69 $argumentsSection->addChild(
'title',
'Arguments');
71 return $docbookSection;
82 protected function addArguments($className, \SimpleXMLElement $docbookSection) {
84 $argumentDefinitions = $viewHelper->prepareArguments();
85 if (count($argumentDefinitions) === 0) {
86 $docbookSection->addChild(
'para',
'No arguments defined.');
89 $argumentsTable = $docbookSection->addChild(
'table');
90 $argumentsTable->addChild(
'title',
'Arguments');
91 $tgroup = $argumentsTable->addChild(
'tgroup');
93 $this->
addArgumentTableRow($tgroup->addChild(
'thead'),
'Name',
'Type',
'Required',
'Description',
'Default');
94 $tbody = $tgroup->addChild(
'tbody');
95 foreach ($argumentDefinitions as $argumentDefinition) {
96 $this->
addArgumentTableRow($tbody, $argumentDefinition->getName(), $argumentDefinition->getType(), $argumentDefinition->isRequired() ?
'yes' :
'no', $argumentDefinition->getDescription(), $argumentDefinition->getDefaultValue());
107 return $this->objectManager->get($className);
119 private function addArgumentTableRow(\SimpleXMLElement $parent, $name, $type, $required, $description, $default) {
120 $row = $parent->addChild(
'row');
121 $row->addChild(
'entry', $name);
122 $row->addChild(
'entry', $type);
123 $row->addChild(
'entry', $required);
124 $row->addChild(
'entry', $description);
125 $row->addChild(
'entry', (
string) $default);
141 $splitRegex =
'/^\\s*(=[^=]+=)$/m';
142 $regex =
'/^\\s*(=([^=]+)=)$/m';
143 $matches = preg_split($splitRegex, $documentation, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
144 $currentSection = $docbookSection;
145 foreach ($matches as $singleMatch) {
146 if (preg_match($regex, $singleMatch, $tmp)) {
147 $currentSection = $docbookSection->addChild(
'section');
148 $currentSection->addChild(
'title', trim($tmp[2]));
150 $this->
addText(trim($singleMatch), $currentSection);
159 protected function addText($text, \SimpleXMLElement $parentElement) {
168 $matches = preg_split($splitRegex, $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
169 foreach ($matches as $singleMatch) {
170 if (preg_match($regex, $singleMatch, $tmp)) {
171 preg_match(
'/title="([^"]+)"/', $tmp[1], $titleMatch);
172 $example = $parentElement->addChild(
'example');
173 if (count($titleMatch)) {
174 $example->addChild(
'title', trim($titleMatch[1]));
176 $example->addChild(
'title',
'Example');
180 $textParts = explode(
"\n", $singleMatch);
181 foreach ($textParts as $text) {
182 if (trim($text) ===
'') {
addDocumentation($documentation, \SimpleXMLElement $docbookSection)
addChildWithCData(\SimpleXMLElement $parentXmlNode, $childNodeName, $childNodeValue)
addArgumentTableRow(\SimpleXMLElement $parent, $name, $type, $required, $description, $default)
instanciateViewHelper($className)
generateDocbook($namespace)
generateXmlForClassName($className, $namespace, \SimpleXMLElement $xmlRootNode)
const NAMESPACE_SEPARATOR
getTagNameForClass($className, $namespace)
addArguments($className, \SimpleXMLElement $docbookSection)
addText($text, \SimpleXMLElement $parentElement)
getClassNamesInNamespace($namespace)