-
Notifications
You must be signed in to change notification settings - Fork 24
phpDocumentor Guides integration #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
wouterj
wants to merge
20
commits into
symfony-tools:main
Choose a base branch
from
wouterj:phpdocumentor-guides
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
de32bec
Convert docs builder into an extension
wouterj 9935991
Cleanup
wouterj 740d37e
Update to latest Guides
wouterj e6762d1
Upgrade to latest guides and use guides-code's highlighter
wouterj 79757c1
Fix SymfonyExtension build
wouterj 23bc553
Set-up Psalm CI
wouterj 93904c5
Set-up PHP CS Fixer CI
wouterj ffa0a89
Use guides-code from Packagist
wouterj 5d8ad9d
Upgrade to Sphinx RTD Theme 2.0.0
wouterj 36b0b3f
Unskip fixed test cases
wouterj 196800c
Upgrade Guides and split RTD theme
wouterj d7e919e
Do not use anchors for document links in toctree
wouterj 81d04e5
Enable toctree project test
wouterj 0a22f2a
Fix CI
wouterj 569b74d
Fix CS
wouterj 8bb7240
Upgrade to Guides 1.0
wouterj 2d6f640
Made last skipped test green
wouterj 275497b
Upgrade to latest Guides
wouterj c954ea7
Upgrade other dependencies
wouterj 4965a7d
Merge phpDocumentor Guides extension in the DocsBuilder
wouterj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| /vendor/ | ||
| /tests/_output | ||
| /tests/_cache | ||
| /var/ | ||
| /docs.phar | ||
| /.env | ||
| /.phpunit.cache/ | ||
| /.phpunit.result.cache | ||
| /.php-cs-fixer.cache | ||
| /composer.lock | ||
| vendor/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?php | ||
|
|
||
| $fileHeaderComment = <<<EOT | ||
| This file is part of the Guides SymfonyExtension package. | ||
|
|
||
| (c) Wouter de Jong | ||
|
|
||
| For the full copyright and license information, please view the LICENSE | ||
| file that was distributed with this source code. | ||
| EOT; | ||
|
|
||
| return (new PhpCsFixer\Config()) | ||
| ->setRules([ | ||
| '@PHP71Migration' => true, | ||
| '@PHPUnit75Migration:risky' => true, | ||
| '@Symfony' => true, | ||
| '@Symfony:risky' => true, | ||
| 'protected_to_private' => false, | ||
| 'native_constant_invocation' => ['strict' => false], | ||
| 'no_superfluous_phpdoc_tags' => [ | ||
| 'remove_inheritdoc' => true, | ||
| 'allow_unused_params' => true, // for future-ready params, to be replaced with https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7377 | ||
| ], | ||
| 'header_comment' => ['header' => $fileHeaderComment], | ||
| 'modernize_strpos' => true, | ||
| 'get_class_to_class_keyword' => true, | ||
| 'nullable_type_declaration' => true, | ||
| ]) | ||
| ->setRiskyAllowed(true) | ||
| ->setFinder( | ||
| (new PhpCsFixer\Finder()) | ||
| ->in(__DIR__.'/src') | ||
| ) | ||
| ; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Docs Builder package. | ||
| * | ||
| * (c) Ryan Weaver <[email protected]> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
|
||
| use phpDocumentor\Guides\RestructuredText\Parser\Productions\DirectiveContentRule; | ||
| use phpDocumentor\Guides\RestructuredText\TextRoles\TextRole; | ||
|
|
||
| return static function (ContainerConfigurator $container) { | ||
| $container->services() | ||
| ->defaults()->autowire() | ||
|
|
||
| ->load('SymfonyDocsBuilder\\Directives\\', '../src/Directives') | ||
| ->bind('$startingRule', service(DirectiveContentRule::class)) | ||
| ->tag('phpdoc.guides.directive') | ||
|
|
||
| ->load('SymfonyDocsBuilder\\TextRole\\', '../src/TextRole') | ||
| ->tag('phpdoc.guides.parser.rst.text_role') | ||
| ; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Docs Builder package. | ||
| * | ||
| * (c) Ryan Weaver <[email protected]> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
|
||
| use SymfonyDocsBuilder\Highlighter\SymfonyHighlighter; | ||
| use SymfonyDocsBuilder\NodeRenderer\CodeNodeRenderer; | ||
| use SymfonyDocsBuilder\NodeRenderer\MenuEntryRenderer; | ||
| use SymfonyDocsBuilder\Node\ExternalLinkNode; | ||
| use SymfonyDocsBuilder\Twig\CodeExtension; | ||
| use SymfonyDocsBuilder\Twig\UrlExtension; | ||
| use Twig\Extension\ExtensionInterface; | ||
| use Twig\Extra\String\StringExtension; | ||
| use phpDocumentor\Guides\Code\Highlighter\Highlighter; | ||
| use phpDocumentor\Guides\NodeRenderers\NodeRenderer; | ||
| use phpDocumentor\Guides\NodeRenderers\TemplateNodeRenderer; | ||
|
|
||
| return static function (ContainerConfigurator $container) { | ||
| $container ->services() | ||
| ->defaults()->autowire()->autoconfigure() | ||
| ->instanceof(ExtensionInterface::class)->tag('twig.extension') | ||
| ->instanceof(NodeRenderer::class)->tag('phpdoc.guides.noderenderer.html', ['priority' => 10]) | ||
|
|
||
| ->set(CodeExtension::class) | ||
| ->set(UrlExtension::class) | ||
| ->set(StringExtension::class) | ||
|
|
||
| ->set(CodeNodeRenderer::class) | ||
| ->set(MenuEntryRenderer::class) | ||
|
|
||
| ->set('symfony.node_renderer.html.inline.external_link', TemplateNodeRenderer::class) | ||
| ->arg('$template', 'inline/external-link.html.twig') | ||
| ->arg('$nodeClass', ExternalLinkNode::class) | ||
|
|
||
| ->set(SymfonyHighlighter::class) | ||
| ->decorate(Highlighter::class) | ||
| ; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Docs Builder package. | ||
| * | ||
| * (c) Ryan Weaver <[email protected]> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
|
||
| use Psr\EventDispatcher\EventDispatcherInterface; | ||
| use SymfonyDocsBuilder\Build\BuildConfig; | ||
| use SymfonyDocsBuilder\DocBuilder; | ||
| use Symfony\Component\Console\Output\ConsoleOutput; | ||
| use Symfony\Component\EventDispatcher\EventDispatcher; | ||
|
|
||
| return static function (ContainerConfigurator $container) { | ||
| $container->services() | ||
| ->defaults()->autowire() | ||
|
|
||
| ->set(EventDispatcherInterface::class, EventDispatcher::class) | ||
|
|
||
| ->set(BuildConfig::class) | ||
|
|
||
| ->set(DocBuilder::class)->public() | ||
| ; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.4/phpunit.xsd" | ||
| bootstrap="vendor/autoload.php" | ||
| beStrictAboutOutputDuringTests="true" | ||
| failOnDeprecation="true" | ||
| failOnRisky="true" | ||
| failOnWarning="true" | ||
| cacheDirectory=".phpunit.cache" | ||
| beStrictAboutCoverageMetadata="true"> | ||
| <testsuites> | ||
| <testsuite name="default"> | ||
| <directory>tests</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
|
|
||
| <source ignoreSuppressionOfDeprecations="true" | ||
| ignoreIndirectDeprecations="true" | ||
| restrictNotices="true" | ||
| restrictWarnings="true"> | ||
| <include> | ||
| <directory>src</directory> | ||
| </include> | ||
|
|
||
| <deprecationTrigger> | ||
| <function>trigger_deprecation</function> | ||
| <method>Doctrine\Deprecations\Deprecation::trigger</method> | ||
| <method>Doctrine\Deprecations\Deprecation::delegateTriggerToBackend</method> | ||
| </deprecationTrigger> | ||
| </source> | ||
| </phpunit> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <?xml version="1.0"?> | ||
| <psalm | ||
| errorLevel="2" | ||
| resolveFromConfigFile="true" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns="https://getpsalm.org/schema/config" | ||
| xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
| findUnusedCode="false" | ||
| findUnusedBaselineEntry="true" | ||
| > | ||
| <projectFiles> | ||
| <directory name="src" /> | ||
| <directory name="config" /> | ||
| <ignoreFiles> | ||
| <directory name="vendor" /> | ||
| </ignoreFiles> | ||
| </projectFiles> | ||
|
|
||
| <issueHandlers> | ||
| <ImplicitToStringCast errorLevel="suppress" /> | ||
| </issueHandlers> | ||
| </psalm> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| # Custom Highlight Templates | ||
|
|
||
| The highlight.php library takes its highlighting metadata/rules | ||
| from highlight.js. That library builds the highlighting metadata/rules | ||
| in Node and then outputs them as JSON: | ||
|
|
||
| * Source Language files: https://github.com/highlightjs/highlight.js/tree/master/src/languages | ||
| * Final Language files: https://github.com/scrivo/highlight.php/tree/master/Highlight/languages | ||
|
|
||
| In a few cases, we've extended the language rules, which (in theory) | ||
| should make it back upstream to highlight.js. These files began | ||
| as copies of the .json files (which were then prettified) then extended. | ||
|
|
||
| A few things we've learned about how the language files work: | ||
|
|
||
| * `begin` is the regex that marks the beginning of something | ||
| * `end` is optional. Without it, `begin` will be used, and as | ||
| soon as it finds a non-matching character, it will stop. | ||
| If you have a situation where using begin is causing | ||
| over-matching, then you can use end to tell it exactly where | ||
| to stop. | ||
| * `excludeEnd` can be used to match an entire string with `begin` | ||
| and `end`, but then only apply the class name to the part | ||
| matched by `start`. This was useful with `::` where we wanted | ||
| to match `::` THEN some valid string (to avoid over-matching | ||
| `::` in other situations). But, we only wanted the class name | ||
| applied to the `start` part (the `::` part). | ||
| * `contains` the way for building embedded rules. `function` is | ||
| a nice example, which outlines the `start` and `end` and then | ||
| also outlines some items that will be embedded inside of it. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why adding support for older versions ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note. On symfony.com we run 8.4 and soon, 8.5 so we can safely use modern PHP versions.