-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
So the origin of the menu's not working is in the way the menu's are defined. The doctrine parser did use * as a deep search wildcard which is not according to the behavior sphinx does it. As the toctree is a directive defined by sphinx we try to follow that one closely. The correct way of writing a toctree is ``` .. toctree:: :glob: ** ``` This will include all documents and sections in a project. starting at the level of the current page.
- Loading branch information
Showing
5 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
|
@@ -28,7 +28,7 @@ class RSTCopier | |
:depth: 3 | ||
:glob: | ||
* | ||
** | ||
SIDEBAR; | ||
|
||
public function __construct( | ||
|
This file contains 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,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Website\Guides\Compiler; | ||
|
||
use phpDocumentor\Guides\Compiler\CompilerContext; | ||
use phpDocumentor\Guides\Compiler\NodeTransformer; | ||
use phpDocumentor\Guides\Nodes\Menu\GlobMenuEntryNode; | ||
use phpDocumentor\Guides\Nodes\Node; | ||
|
||
/** | ||
* This class will fix the glob menu entries. | ||
* | ||
* The glob menu entries are not correctly added in the docs. | ||
* This transformer will fix the glob menu entries by replacing the '*' with '**'. This add a certain | ||
* risk if the user had the intention to match only documents in the current directory. But this can be solved | ||
* adding a `/` at the beginning of the glob pattern. | ||
* | ||
* @implements NodeTransformer<GlobMenuEntryNode> | ||
*/ | ||
final class GlobMenuFixerTransformer implements NodeTransformer | ||
{ | ||
public function enterNode(Node $node, CompilerContext $compilerContext): Node | ||
{ | ||
return $node; | ||
} | ||
|
||
public function leaveNode(Node $node, CompilerContext $compilerContext): Node|null | ||
{ | ||
if ($node->getUrl() === '*') { | ||
return new GlobMenuEntryNode( | ||
'**', | ||
$node->getLevel(), | ||
); | ||
} | ||
|
||
return $node; | ||
} | ||
|
||
public function supports(Node $node): bool | ||
{ | ||
return $node instanceof GlobMenuEntryNode; | ||
} | ||
|
||
public function getPriority(): int | ||
{ | ||
// Before GlobMenuEntryNodeTransformer | ||
return 4001; | ||
} | ||
} |