Skip to content

Commit f15f133

Browse files
committed
clean references
1 parent 2faee09 commit f15f133

14 files changed

+57
-31
lines changed

_build/composer.lock

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

_build/conf.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"version": "4.0"
2+
"version": "4.0",
3+
"symfony_api_url": "https://api.symfony.com",
4+
"php_doc_url": "https://secure.php.net/manual/en"
35
}

_build/notes.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@ Notes
2323
- we're assuming there is only one toctree per page...
2424
- `rst` does not exist in highlight php
2525
- `varnish` = C ? (highlight php)
26+
27+
Bugs in RST Parser
28+
==================
29+
30+
- problem using glob: listed files are added twice (https://github.com/doctrine/rst-parser/issues/18)
31+
- problem with absolute path in toc trees (https://github.com/doctrine/rst-parser/pull/23)
32+
- problem with `_build` directory indexed (test case to create)
33+
- problem with `:ref:`, `:doc:` and `*.rst.inc` which are loaded in parseQueue (problem evoked in https://github.com/doctrine/rst-parser/pull/23)
34+
- problem with `.. include::` which are SOMETIMES failing to load (dirty fix in `UrlGenerator::relativeUrl`)

_build/src/HtmlKernel.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
namespace SymfonyDocs;
44

5-
use Doctrine\RST\HTML\Document;
65
use Doctrine\RST\DefaultNodeFactory;
7-
use Doctrine\RST\Directive;
8-
use Doctrine\RST\NodeFactory as NodeFactoryInterface;
6+
use Doctrine\RST\HTML\Document;
97
use Doctrine\RST\HTML\Kernel;
8+
use Doctrine\RST\HTML\Nodes as ParserNodes;
9+
use Doctrine\RST\NodeFactory as NodeFactoryInterface;
1010
use Doctrine\RST\NodeInstantiator;
1111
use Doctrine\RST\NodeTypes;
12-
use Doctrine\RST\HTML\Nodes as ParserNodes;
1312
use SymfonyDocs\Directive as SymfonyDoirectives;
1413
use SymfonyDocs\Nodes as SymfonyNodes;
1514
use SymfonyDocs\Reference as SymfonyRefernces;
@@ -37,6 +36,24 @@ public static function getVersion(): string
3736
return self::getConfiguration()['version'];
3837
}
3938

39+
public static function getSymfonyApiUrl(): string
40+
{
41+
if (!isset(self::getConfiguration()['symfony_api_url'])) {
42+
throw new \RuntimeException('The "symfony_api_url" must be defined in "/_build/conf.json"');
43+
}
44+
45+
return self::getConfiguration()['symfony_api_url'];
46+
}
47+
48+
public static function getPhpDocUrl(): string
49+
{
50+
if (!isset(self::getConfiguration()['php_doc_url'])) {
51+
throw new \RuntimeException('The "php_doc_url" must be defined in "/_build/conf.json"');
52+
}
53+
54+
return self::getConfiguration()['php_doc_url'];
55+
}
56+
4057
public function getDirectives(): array
4158
{
4259
$directives = parent::getDirectives();
@@ -74,7 +91,7 @@ public function getReferences(): array
7491
];
7592
}
7693

77-
protected function createNodeFactory() : NodeFactoryInterface
94+
protected function createNodeFactory(): NodeFactoryInterface
7895
{
7996
return new DefaultNodeFactory(
8097
new NodeInstantiator(NodeTypes::ANCHOR, SymfonyNodes\AnchorNode::class),

_build/src/Nodes/CodeNode.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class CodeNode extends Base
1616
'ini' => 'ini',
1717
'bash' => 'bash',
1818
'html+twig' => 'twig',
19+
'jinja' => 'twig',
1920
'html+php' => 'html',
2021
'php-annotations' => 'php',
2122
'text' => 'text',
@@ -26,6 +27,7 @@ class CodeNode extends Base
2627
'php-symfony' => 'php',
2728
'varnish4' => 'c',
2829
'varnish3' => 'c',
30+
'json' => 'json',
2931
];
3032

3133
private const CODE_BLOCK_TEMPLATE = <<< TEMPLATE

_build/src/Reference/ClassReference.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
class ClassReference extends Reference
1111
{
12-
private const BASE__URL = 'https://api.symfony.com';
13-
1412
public function getName(): string
1513
{
1614
return 'class';
@@ -22,7 +20,7 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
2220

2321
return new ResolvedReference(
2422
substr(strrchr($className, '\\'), 1),
25-
sprintf('%s/%s/%s.html', self::BASE__URL, HtmlKernel::getVersion(), str_replace('\\', '/', $className)),
23+
sprintf('%s/%s/%s.html', HtmlKernel::getSymfonyApiUrl(), HtmlKernel::getVersion(), str_replace('\\', '/', $className)),
2624
[],
2725
[
2826
'class' => 'reference external',

_build/src/Reference/MethodReference.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
class MethodReference extends Reference
1111
{
12-
private const BASE__URL = 'https://api.symfony.com';
13-
1412
public function getName(): string
1513
{
1614
return 'method';
@@ -25,7 +23,7 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
2523

2624
return new ResolvedReference(
2725
$methodName.'()',
28-
sprintf('%s/%s/%s.html#method_%s', self::BASE__URL, HtmlKernel::getVersion(), str_replace('\\', '/', $className), $methodName),
26+
sprintf('%s/%s/%s.html#method_%s', HtmlKernel::getSymfonyApiUrl(), HtmlKernel::getVersion(), str_replace('\\', '/', $className), $methodName),
2927
[],
3028
[
3129
'class' => 'reference external',

_build/src/Reference/NamespaceReference.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
class NamespaceReference extends Reference
1111
{
12-
private const BASE__URL = 'https://api.symfony.com';
13-
1412
public function getName(): string
1513
{
1614
return 'namespace';
@@ -22,7 +20,7 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
2220

2321
return new ResolvedReference(
2422
substr(strrchr($className, '\\'), 1),
25-
sprintf('%s/%s/%s.html', self::BASE__URL, HtmlKernel::getVersion(), str_replace('\\', '/', $className)),
23+
sprintf('%s/%s/%s.html', HtmlKernel::getSymfonyApiUrl(), HtmlKernel::getVersion(), str_replace('\\', '/', $className)),
2624
[],
2725
[
2826
'class' => 'reference external',

_build/src/Reference/PhpClassReference.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
use Doctrine\RST\Environment;
66
use Doctrine\RST\Reference;
77
use Doctrine\RST\References\ResolvedReference;
8+
use SymfonyDocs\HtmlKernel;
89

910
class PhpClassReference extends Reference
1011
{
11-
private const BASE__URL = 'https://secure.php.net/manual/en/class.%s.php';
12-
1312
public function getName(): string
1413
{
1514
return 'phpclass';
@@ -19,7 +18,7 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
1918
{
2019
return new ResolvedReference(
2120
$data,
22-
sprintf(self::BASE__URL, strtolower($data)),
21+
sprintf('%s/class.%s.php', HtmlKernel::getPhpDocUrl(), strtolower($data)),
2322
[],
2423
[
2524
'class' => 'reference external',

_build/src/Reference/PhpFunctionReference.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
use Doctrine\RST\Environment;
66
use Doctrine\RST\Reference;
77
use Doctrine\RST\References\ResolvedReference;
8+
use SymfonyDocs\HtmlKernel;
89

910
class PhpFunctionReference extends Reference
1011
{
11-
private const BASE__URL = 'https://secure.php.net/manual/en/function.%s.php';
12-
1312
public function getName(): string
1413
{
1514
return 'phpfunction';
@@ -19,7 +18,7 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
1918
{
2019
return new ResolvedReference(
2120
$data,
22-
sprintf(self::BASE__URL, str_replace('_', '-', strtolower($data))),
21+
sprintf('%s/function.%s.php', HtmlKernel::getPhpDocUrl(), str_replace('_', '-', strtolower($data))),
2322
[],
2423
[
2524
'class' => 'reference external',

_build/src/Reference/PhpMethodReference.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
use Doctrine\RST\Environment;
66
use Doctrine\RST\Reference;
77
use Doctrine\RST\References\ResolvedReference;
8+
use SymfonyDocs\HtmlKernel;
89

910
class PhpMethodReference extends Reference
1011
{
11-
private const BASE__URL = 'https://secure.php.net/manual/en/%s.%s.php';
12-
1312
public function getName(): string
1413
{
1514
return 'phpmethod';
@@ -22,11 +21,11 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
2221

2322
return new ResolvedReference(
2423
$data.'()',
25-
sprintf(self::BASE__URL, strtolower($class), strtolower($method)),
24+
sprintf('%s/%s.%s.php', HtmlKernel::getPhpDocUrl(), strtolower($class), strtolower($method)),
2625
[],
2726
[
2827
'class' => 'reference external',
29-
'title' => $class
28+
'title' => $class,
3029
]
3130
);
3231
}

_build/src/Reference/RefReference.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,9 @@ public function resolve(Environment $environment, string $data): ResolvedReferen
2424

2525
return $resolvedReference;
2626
}
27+
28+
public function found(Environment $environment, string $data) : void
29+
{
30+
$environment->addDependency($data);
31+
}
2732
}

reference/forms/twig_reference.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ This test will check if the current ``form`` does not have a parent form view.
239239
{{ form_errors(form) }}
240240
{% endif %}
241241
242-
.. _`twig-reference-form-variables`:
242+
.. _twig-reference-form-variables:
243243

244244
More about Form Variables
245245
-------------------------

security.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ Your next steps depend on your setup:
619619
* Learn how to deny access, load the User object and deal with roles in the
620620
:ref:`Authorization <security-authorization>` section.
621621

622-
.. _`security-authorization`:
622+
.. _security-authorization:
623623

624624
2) Denying Access, Roles and other Authorization
625625
------------------------------------------------

0 commit comments

Comments
 (0)