Skip to content

Commit

Permalink
Fix static page links
Browse files Browse the repository at this point in the history
Static pages do not have an source to find references, so static
html links are used. Guides does see them as invalid links. This new
resolver allows us to accept the static links as valid and uses the targetreference
as url.
  • Loading branch information
jaapio committed Oct 15, 2024
1 parent e106d09 commit 5cfe74d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
4 changes: 4 additions & 0 deletions config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@
<tag name="phpdoc.guides.noderenderer.html" />
</service>

<service id="Doctrine\Website\Guides\ReferenceResolver\HtmlResolver">
<tag name="phpdoc.guides.reference_resolver" />
</service>

<service id="Doctrine\Website\Guides\Compiler\GlobMenuFixerTransformer">
<tag name="phpdoc.guides.compiler.nodeTransformers" />
</service>
Expand Down
30 changes: 30 additions & 0 deletions lib/Guides/ReferenceResolver/HtmlResolver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

namespace Doctrine\Website\Guides\ReferenceResolver;

use phpDocumentor\Guides\Nodes\Inline\LinkInlineNode;
use phpDocumentor\Guides\ReferenceResolvers\Message;

Check failure on line 8 in lib/Guides/ReferenceResolver/HtmlResolver.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Type phpDocumentor\Guides\ReferenceResolvers\Message is not used in this file.
use phpDocumentor\Guides\ReferenceResolvers\Messages;
use phpDocumentor\Guides\ReferenceResolvers\ReferenceResolver;
use phpDocumentor\Guides\RenderContext;

class HtmlResolver implements ReferenceResolver
{

Check failure on line 14 in lib/Guides/ReferenceResolver/HtmlResolver.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Opening brace must not be followed by a blank line

Check failure on line 14 in lib/Guides/ReferenceResolver/HtmlResolver.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

There must be exactly 0 empty lines after class opening brace.

public function resolve(LinkInlineNode $node, RenderContext $renderContext, Messages $messages): bool

Check failure on line 16 in lib/Guides/ReferenceResolver/HtmlResolver.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Expected 0 blank lines before function; 1 found
{
if (str_ends_with($node->getTargetReference(), '.html')) {

Check failure on line 18 in lib/Guides/ReferenceResolver/HtmlResolver.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Function str_ends_with() should not be referenced via a fallback global name, but via a use statement.
$node->setUrl($node->getTargetReference());
return true;

Check failure on line 20 in lib/Guides/ReferenceResolver/HtmlResolver.php

View workflow job for this annotation

GitHub Actions / Coding Standards / Coding Standards (8.3)

Expected 1 line before "return", found 0.
}

return false;
}

public static function getPriority(): int
{
return -300;
}
}
4 changes: 2 additions & 2 deletions source/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ Maintainer Workflow
-------------------

You can learn more about the maintainer workflow
`here </maintainer/>`_. Continue reading if you are
`here </maintainer/index.html>`_. Continue reading if you are
interested in learning more about how to get started with your first
contribution.

Expand All @@ -556,4 +556,4 @@ Website
The `doctrine-project.org <https://www.doctrine-project.org/>`_ website
is completely open source! If you want to learn how to contribute to the
Doctrine website and documentation you can read more about it
`here </website/>`_.
`here <website/index.html>`_.
2 changes: 1 addition & 1 deletion source/policies/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ issue tracker in GitHub and don't publish it publicly. Instead, all security iss
must be sent to `[email protected] <mailto:[email protected]>`_.
Emails sent to this address are forwarded to the Doctrine core team private mailing-list.

.. notice::
.. note::

While we are working on a patch, please do not reveal the issue publicly. The resolution can take
anywhere between a couple of days, a month or an indefinite amount of time depending on its complexity.
Expand Down

0 comments on commit 5cfe74d

Please sign in to comment.