2 namespace TYPO3\CMS\Fluid\Service;
31 $namespace .= \TYPO3\CMS\Fluid\Fluid::NAMESPACE_SEPARATOR;
34 $xmlRootNode = new \SimpleXMLElement(
'<?xml version="1.0" encoding="UTF-8"?>
35 <section version="5.0" xmlns="http://docbook.org/ns/docbook"
36 xml:id="fluid.usermanual.standardviewhelpers"
37 xmlns:xl="http://www.w3.org/1999/xlink"
38 xmlns:xi="http://www.w3.org/2001/XInclude"
39 xmlns:xhtml="http://www.w3.org/1999/xhtml"
40 xmlns:svg="http://www.w3.org/2000/svg"
41 xmlns:ns="http://docbook.org/ns/docbook"
42 xmlns:mathml="http://www.w3.org/1998/Math/MathML">
43 <title>Standard View Helper Library</title>
45 <para>Should be autogenerated from the tags.</para>
47 foreach ($classNames as $className) {
50 return $xmlRootNode->asXML();
63 $reflectionClass = new \TYPO3\CMS\Extbase\Reflection\ClassReflection($className);
64 if (!$reflectionClass->isSubclassOf($this->abstractViewHelperReflectionClass)) {
68 $docbookSection = $xmlRootNode->addChild(
'section');
69 $docbookSection->addChild(
'title', $tagName);
70 $this->docCommentParser->parseDocComment($reflectionClass->getDocComment());
71 $this->
addDocumentation($this->docCommentParser->getDescription(), $docbookSection);
72 $argumentsSection = $docbookSection->addChild(
'section');
73 $argumentsSection->addChild(
'title',
'Arguments');
75 return $docbookSection;
86 protected function addArguments($className, \SimpleXMLElement $docbookSection)
89 $argumentDefinitions = $viewHelper->prepareArguments();
90 if (count($argumentDefinitions) === 0) {
91 $docbookSection->addChild(
'para',
'No arguments defined.');
94 $argumentsTable = $docbookSection->addChild(
'table');
95 $argumentsTable->addChild(
'title',
'Arguments');
96 $tgroup = $argumentsTable->addChild(
'tgroup');
98 $this->
addArgumentTableRow($tgroup->addChild(
'thead'),
'Name',
'Type',
'Required',
'Description',
'Default');
99 $tbody = $tgroup->addChild(
'tbody');
100 foreach ($argumentDefinitions as $argumentDefinition) {
101 $this->
addArgumentTableRow($tbody, $argumentDefinition->getName(), $argumentDefinition->getType(), $argumentDefinition->isRequired() ?
'yes' :
'no', $argumentDefinition->getDescription(), $argumentDefinition->getDefaultValue());
113 return $this->objectManager->get($className);
125 private function addArgumentTableRow(\SimpleXMLElement $parent, $name, $type, $required, $description, $default)
127 $row = $parent->addChild(
'row');
128 $row->addChild(
'entry', $name);
129 $row->addChild(
'entry', $type);
130 $row->addChild(
'entry', $required);
131 $row->addChild(
'entry', $description);
132 $row->addChild(
'entry', (
string)$default);
149 $splitRegex =
'/^\\s*(=[^=]+=)$/m';
150 $regex =
'/^\\s*(=([^=]+)=)$/m';
151 $matches = preg_split($splitRegex, $documentation, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
152 $currentSection = $docbookSection;
153 foreach ($matches as $singleMatch) {
154 if (preg_match($regex, $singleMatch, $tmp)) {
155 $currentSection = $docbookSection->addChild(
'section');
156 $currentSection->addChild(
'title', trim($tmp[2]));
158 $this->
addText(trim($singleMatch), $currentSection);
167 protected function addText($text, \SimpleXMLElement $parentElement)
177 $matches = preg_split($splitRegex, $text, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
178 foreach ($matches as $singleMatch) {
179 if (preg_match($regex, $singleMatch, $tmp)) {
180 preg_match(
'/title="([^"]+)"/', $tmp[1], $titleMatch);
181 $example = $parentElement->addChild(
'example');
182 if (count($titleMatch)) {
183 $example->addChild(
'title', trim($titleMatch[1]));
185 $example->addChild(
'title',
'Example');
189 $textParts = explode(
"\n", $singleMatch);
190 foreach ($textParts as $text) {
191 if (trim($text) ===
'') {