Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "namelesscoder/fluid-documentation-generator",
"require": {
"ext-simplexml": "*",
"typo3fluid/fluid": "dev-master",
"php": "^7.1",
"cebe/markdown": "^1.2"
Expand Down
10 changes: 10 additions & 0 deletions resources/templates/Default/ViewHelper.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ <h2>ViewHelpers</h2>
<h1>ViewHelper Documentation</h1>
<h2><code>{f:if(condition: metadata.namespace.alias, then: '{metadata.namespace.alias}:')}{viewHelper.name}</code></h2>

<section class="divider">
<h4>Fluid XML namespace</h4>
<p>
<code>&lt;html ...
<strong>xmlns:{viewHelper.schema.schema.package.packageName}="{viewHelper.schema.fluidNamespace}"</strong>
data-namespace-typo3-fluid="true"&gt;
</code>
</p>
</section>

<section class="divider">
<f:if condition="{viewHelper.description}">
<f:then>
Expand Down
8 changes: 8 additions & 0 deletions resources/templates/Default/ViewHelper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
{headline}
{headlineDecoration}

Fluid XML namespace
-------------------

.. code-block:: html

<html ...
xmlns:{viewHelper.schema.schema.package.packageName}="{viewHelper.schema.fluidNamespace}"
data-namespace-typo3-fluid="true>

{viewHelper.description -> f:format.raw()}

Expand Down
31 changes: 31 additions & 0 deletions src/ProcessedSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class ProcessedSchema
*/
private $viewHelpersDocumentations = [];

/**
* @var string|null
*/
private $fluidNamespace;

public function __construct(Schema $schema)
{
$this->schema = $schema;
Expand Down Expand Up @@ -61,11 +66,37 @@ public function getDocumentedViewHelpers(): array
return $this->viewHelpersDocumentations;
}

/**
* @return ViewHelperDocumentationGroup
*/
public function getViewHelperDocumentationRootGroup(): ViewHelperDocumentationGroup
{
return $this->viewHelperDocumentationRootGroup;
}

/**
* @return ViewHelperDocumentation[]
*/
public function getViewHelpersDocumentations(): array
{
return $this->viewHelpersDocumentations;
}

/**
* @return string|null
*/
public function getFluidNamespace(): ?string
{
return $this->fluidNamespace;
}

private function processXmlFile(): array
{
$json = [];
$xmlFilePath = DataFileResolver::getInstance()->resolveSchemaFileLocation($this->schema);
$xmlDocument = simplexml_load_file($xmlFilePath);
$targetNamespace = $xmlDocument->xpath('/xsd:schema[@targetNamespace]')[0]['targetNamespace'];
$this->fluidNamespace = $targetNamespace ? (string)$targetNamespace : null;
foreach ($xmlDocument->xpath('/xsd:schema/xsd:element') as $element) {
$name = (string)$element->attributes()['name'];
$group = $this->findOrCreateViewHelperDocumentationGroupByViewHelperName($name);
Expand Down
8 changes: 8 additions & 0 deletions src/ViewHelperDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ public function getDescription(): string
return $this->description;
}

/**
* @return string
*/
public function getViewHelperName(): string
{
return $this->viewHelperName;
}

public function getPathToSchemaRoot(): string
{
return str_repeat('../', substr_count($this->viewHelperName, '.'));
Expand Down