Skip to content

Commit

Permalink
[BUGFIX] Improve line breaking issues for tables
Browse files Browse the repository at this point in the history
  • Loading branch information
linawolf committed Feb 4, 2025
1 parent 16fd935 commit 4ca97e0
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<section data-search-title="{{ node.path }}{{ node.plainContent }}"
<section data-search-title="{{ node.composerPath }}{{ node.plainContent }}"
data-search-id="{{ node.anchor }}"
data-search-facet="file"
class="confval-section"
>
<h3 class="sr-only">{{ node.path }}{{ node.plainContent }}</h3>
<h3 class="sr-only">{{ node.composerPath }}{{ node.plainContent }}</h3>
<dl class="confval">
<dt{% if not node.noindex %} id="{{ node.anchor }}"{% endif %}
class="d-flex justify-content-between">
Expand Down Expand Up @@ -31,17 +31,13 @@
<dt class="field-even">Scope</dt>
<dd class="field-even">{{ node.scope }}</dd>
{% endif -%}
{% if node.path %}
<dt class="field-even">Path</dt>
<dd class="field-even">{{ node.path }}{{ node.plainContent }}</dd>
{% endif -%}
{% if node.composerPathPrefix or node.composerPath %}
<dt class="field-even">Path (Composer)</dt>
<dd class="field-even">{{ node.composerPathPrefix }}{{ node.composerPath }}{{ node.path }}{{ node.plainContent }}</dd>
<dd class="field-even">{{ node.composerPathPrefix }}{{ node.composerPath }}{{ node.plainContent }}</dd>
{% endif -%}
{%- if node.classicPathPrefix or node.classicPath %}
<dt class="field-odd">Path (Classic)</dt>
<dd class="field-odd">{{ node.classicPathPrefix }}{{ node.classicPath }}{{ node.path }}{{ node.plainContent }}</dd>
<dd class="field-odd">{{ node.classicPathPrefix }}{{ node.classicPath }}{{ node.plainContent }}</dd>
{% endif -%}
{% if node.configuration %}
<dt class="field-odd">Configuration</dt>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ public function enterNode(Node $node, CompilerContextInterface $compilerContext)
}
/** @var DataObject[] $fileObjects */
$fileObjects = $this->objectInventory->getGroup(FileObject::KEY);
foreach ($fileObjects as $fileObject) {
if (!$fileObject instanceof FileObject) {
continue;
}
if ($fileObject->id === $node->getFileLink()) {
$node->setFileObject($fileObject);
return $node;
}
if (preg_match($fileObject->regex, $node->getFileLink())) {
$node->setFileObject($fileObject);
break;
}
}
foreach ($fileObjects as $fileObject) {
if (!$fileObject instanceof FileObject) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ protected function processSub(
id: $key,
fileName: $filename,
language: $language,
path: $this->getPath($path),
composerPath: $this->getPath($directive->getOptionString('composerPath')),
composerPath: $directive->hasOption('composerPath') ? $this->getPath($directive->getOptionString('composerPath')) : $this->getPath($path),
composerPathPrefix: $this->getPath($pathPrefix),
classicPath: $this->getPath($directive->getOptionString('classicPath')),
classicPath: $directive->hasOption('classicPath') ? $this->getPath($directive->getOptionString('classicPath')) : $this->getPath($path),
classicPathPrefix: $this->getPath($classicPathPrefix),
scope: $directive->getOptionString('scope'),
regex: $regex,
Expand Down
6 changes: 0 additions & 6 deletions packages/typo3-docs-theme/src/Nodes/Typo3FileNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public function __construct(
private readonly string $id,
private readonly string $fileName,
private readonly string $language,
private readonly string $path,
private readonly string $composerPath = '',
private readonly string $composerPathPrefix = '',
private readonly string $classicPath = '',
Expand Down Expand Up @@ -53,11 +52,6 @@ public function getLanguage(): string
return $this->language;
}

public function getPath(): string
{
return $this->path;
}

public function getClassicPath(): string
{
return $this->classicPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class FileObject implements DataObject
public function __construct(
public string $fileName,
public string $language,
public string $path,
public string $composerPath = '',
public string $composerPathPrefix = '',
public string $classicPath = '',
Expand All @@ -26,7 +25,6 @@ public static function fromTypo3Node(Typo3FileNode $node): FileObject
return new FileObject(
$node->getFileName(),
$node->getLanguage(),
$node->getPath(),
$node->getComposerPath(),
$node->getComposerPathPrefix(),
$node->getClassicPath(),
Expand Down
33 changes: 22 additions & 11 deletions tests/Integration/tests/typo3-file/expected/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h3 class="sr-only">Configuration/page.tsconfig</h3>
data-bs-toggle="modal"
data-bs-target="#linkReferenceModal"
data-id="file-extension-configuration-page-tsconfig"
data-rstCode=":file:`packages/my_extension/page.tsconfig`"
data-rstCode=":file:`packages/my_extension/Configuration/page.tsconfig`"
title="Reference this file definition"><i
class="fa-solid fa-paragraph"></i></a>
</div>
Expand All @@ -63,8 +63,6 @@ <h3 class="sr-only">Configuration/page.tsconfig</h3>
<dl class="field-list simple">
<dt class="field-even">Scope</dt>
<dd class="field-even">extension</dd>
<dt class="field-even">Path</dt>
<dd class="field-even">Configuration/page.tsconfig</dd>
<dt class="field-even">Path (Composer)</dt>
<dd class="field-even">packages/my_extension/Configuration/page.tsconfig</dd>
<dt class="field-odd">Path (Classic)</dt>
Expand All @@ -79,12 +77,12 @@ <h3 class="sr-only">Configuration/page.tsconfig</h3>
</dd>
</dl>
</section>
<section data-search-title="settings.php"
<section data-search-title="config/system/settings.php"
data-search-id="file-project-config-system-settings-php"
data-search-facet="file"
class="confval-section"
>
<h3 class="sr-only">settings.php</h3>
<h3 class="sr-only">config/system/settings.php</h3>
<dl class="confval">
<dt id="file-project-config-system-settings-php" class="d-flex justify-content-between">
<div class="confval-header">
Expand Down Expand Up @@ -117,12 +115,12 @@ <h3 class="sr-only">settings.php</h3>
</dd>
</dl>
</section>
<section data-search-title="ENABLE_INSTALL_TOOL"
<section data-search-title="config/ENABLE_INSTALL_TOOL"
data-search-id="file-project-config-enable-install-tool"
data-search-facet="file"
class="confval-section"
>
<h3 class="sr-only">ENABLE_INSTALL_TOOL</h3>
<h3 class="sr-only">config/ENABLE_INSTALL_TOOL</h3>
<dl class="confval">
<dt id="file-project-config-enable-install-tool" class="d-flex justify-content-between">
<div class="confval-header">
Expand Down Expand Up @@ -154,12 +152,12 @@ <h3 class="sr-only">ENABLE_INSTALL_TOOL</h3>
</dd>
</dl>
</section>
<section data-search-title="LOCK_BACKEND"
<section data-search-title="var/lock/LOCK_BACKEND"
data-search-id="file-project-var-lock-lock-backend"
data-search-facet="file"
class="confval-section"
>
<h3 class="sr-only">LOCK_BACKEND</h3>
<h3 class="sr-only">var/lock/LOCK_BACKEND</h3>
<dl class="confval">
<dt id="file-project-var-lock-lock-backend" class="d-flex justify-content-between">
<div class="confval-header">
Expand Down Expand Up @@ -238,12 +236,12 @@ <h3 class="sr-only">config.yaml</h3>
</dd>
</dl>
</section>
<section data-search-title="SomeClass.php"
<section data-search-title="Classes/SomeClass.php"
data-search-id="file-extension-classes-someclass-php"
data-search-facet="file"
class="confval-section"
>
<h3 class="sr-only">SomeClass.php</h3>
<h3 class="sr-only">Classes/SomeClass.php</h3>
<dl class="confval">
<dt id="file-extension-classes-someclass-php" class="d-flex justify-content-between">
<div class="confval-header">
Expand Down Expand Up @@ -368,6 +366,19 @@ <h2>Linking files<a class="headerlink" href="#linking-files" data-bs-toggle="mod
><code class="code-inline file" translate="no">Configuration File</code><i class="fa-regular fa-circle-question"></i></a></li>
<li><code class="code-inline file" translate="no" title="File path">Unknown/<wbr>File.<wbr>xyz</code></li>
<li><code class="code-inline file" translate="no" title="File path">FILE:<wbr>EXT:<wbr>Unknown/<wbr>File.<wbr>xyz</code></li>
<li><a class="composer-link"
href="#file-extension-classes-someclass-php"
title="File Information"
data-bs-toggle="modal"
data-bs-target="#generalModal"
data-filename="SomeClass.php"
data-scope="extension"
data-classicpath="Classes/"
data-composerpath="Classes/"
data-classicpathprefix="typo3conf/ext/my_extension/"
data-composerpathprefix="packages/my_extension/"
data-shortdescription="PHP Classes in this file get auto-loaded"
><code class="code-inline file" translate="no">SomeClass.php</code><i class="fa-regular fa-circle-question"></i></a></li>
</ul>

</section>
Expand Down
6 changes: 3 additions & 3 deletions tests/Integration/tests/typo3-file/input/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ TYPO3 Files
:regex: /.*Configuration\/Sets\/[^\/]+\/config\.yaml$/

.. typo3:file:: SomeClass.php
:path: /
:name: classes-someclass-php
:scope: extension
:composerPath: /Classes/
:classicPath: /Classes/
:path: /Classes/
:regex: /^.*Classes\/.*\.php/
:shortDescription: PHP Classes in this file get auto-loaded

Expand All @@ -73,6 +72,7 @@ Linking files
* :file:`Configuration File <Configuration/Sets/MySet/config.yaml>`
* :file:`Unknown/File.xyz`
* :file:`FILE:EXT:Unknown/File.xyz`
* :file:`SomeClass.php <extension-classes-someclass-php>`

Code Block captions
===================
Expand Down

0 comments on commit 4ca97e0

Please sign in to comment.