Skip to content

Commit 2be3afc

Browse files
authored
[FEAT] use current filename to get the original file name (#788)
This will make markdown rendering work with less errors.
1 parent 40cda82 commit 2be3afc

File tree

12 files changed

+409
-236
lines changed

12 files changed

+409
-236
lines changed

composer.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
"ext-dom": "*",
88
"ext-libxml": "*",
99
"brotkrueml/twig-codehighlight": "^0.1.1",
10-
"phpdocumentor/guides-cli": "^1.0",
10+
"phpdocumentor/guides": "^1.6",
11+
"phpdocumentor/guides-cli": "^1.5",
1112
"phpdocumentor/guides-graphs": "^1.0",
12-
"phpdocumentor/guides-markdown": "^1.0",
13+
"phpdocumentor/guides-markdown": "^1.5",
14+
"phpdocumentor/guides-restructured-text": "^1.5",
1315
"phpdocumentor/guides-theme-bootstrap": "^1.0",
1416
"symfony/clock": "^6.4",
1517
"symfony/finder": "^6.4",
@@ -54,6 +56,7 @@
5456
"config": {
5557
"allow-plugins": {
5658
"ergebnis/composer-normalize": true,
59+
"phpdocumentor/shim": true,
5760
"phpstan/extension-installer": true
5861
},
5962
"platform": {

composer.lock

Lines changed: 163 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/typo3-docs-theme/resources/config/typo3-docs-theme.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Brotkrueml\TwigCodeHighlight\Extension as CodeHighlight;
66
use phpDocumentor\Guides\Event\PostCollectFilesForParsingEvent;
7+
use phpDocumentor\Guides\Event\PostParseDocument;
78
use phpDocumentor\Guides\Event\PostProjectNodeCreated;
89
use phpDocumentor\Guides\Event\PostRenderProcess;
910
use phpDocumentor\Guides\Event\PreParseProcess;
@@ -33,6 +34,7 @@
3334
use T3Docs\Typo3DocsTheme\EventListeners\AddThemeSettingsToProjectNode;
3435
use T3Docs\Typo3DocsTheme\EventListeners\CopyResources;
3536
use T3Docs\Typo3DocsTheme\EventListeners\IgnoreLocalizationsFolders;
37+
use T3Docs\Typo3DocsTheme\EventListeners\OriginalFileNameSetter;
3638
use T3Docs\Typo3DocsTheme\EventListeners\TestingModeActivator;
3739
use T3Docs\Typo3DocsTheme\Inventory\Typo3InventoryRepository;
3840
use T3Docs\Typo3DocsTheme\Packagist\PackagistService;
@@ -197,5 +199,8 @@
197199
->tag('event_listener', ['event' => PostCollectFilesForParsingEvent::class])
198200

199201
->set(TestingModeActivator::class)
200-
->tag('event_listener', ['event' => PreParseProcess::class]);
202+
->tag('event_listener', ['event' => PreParseProcess::class])
203+
204+
->set(OriginalFileNameSetter::class)
205+
->tag('event_listener', ['event' => PostParseDocument::class]);
201206
};

packages/typo3-docs-theme/resources/template/structure/layoutParts/editOnGithubButtons.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{% endif -%}
99
{%- set copySources = getSettings('copy_sources') -%}
1010
{%- if (copySources) %}
11-
<a class="btn btn-sm btn-light" href="{{ copyDownload(env.currentFileName ~ '.rst', '_sources/' ~ env.currentFileName ~ '.rst.txt') }}" rel="nofollow noopener" target="_blank">
11+
<a class="btn btn-sm btn-light" href="{{ copyDownload(sourceFilename(), '_sources/' ~ sourceFilename() ~ '.txt') }}" rel="nofollow noopener" target="_blank">
1212
<span class="btn-icon"><span class="fas fa-code"></span></span>
1313
<span class="btn-text">View source</span>
1414
</a>

packages/typo3-docs-theme/resources/template/structure/navigation/meta-menu.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<p class="caption">Contributors Corner</p>
1010
<ul class="menu-level-1">
1111
{%- if (copySources) %}
12-
<li><a href="{{ copyDownload(env.currentFileName ~ '.rst', '_sources/' ~ env.currentFileName ~ '.rst.txt') }}" rel="nofollow noopener" target="_blank">
12+
<li><a href="{{ copyDownload(sourceFilename(), '_sources/' ~ sourceFilename() ~ '.txt') }}" rel="nofollow noopener" target="_blank">
1313
View source of current document
1414
</a></li>
1515
{% endif -%}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace T3Docs\Typo3DocsTheme\EventListeners;
6+
7+
use phpDocumentor\Guides\Event\PostParseDocument;
8+
9+
final class OriginalFileNameSetter
10+
{
11+
public function __invoke(PostParseDocument $event): void
12+
{
13+
$event->setDocumentNode(
14+
$event->getDocumentNode()?->withKeepExistingOptions(['originalFileName' => $event->getOriginalFileName()])
15+
);
16+
}
17+
}

0 commit comments

Comments
 (0)