Skip to content

Commit cd131b7

Browse files
authored
Merge pull request #1152 from phpDocumentor/backport/1.x/pr-1058
[1.x] Merge pull request #1058 from phpDocumentor/task/rst-theme
2 parents 554bdc9 + e22ba48 commit cd131b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+905
-4
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"phpdocumentor/guides-graphs": "^1.0@dev || ^0.3",
4444
"phpdocumentor/guides-markdown": "^1.0@dev || ^0.3",
4545
"phpdocumentor/guides-restructured-text": "^1.0@dev || ^0.3",
46-
"phpdocumentor/guides-theme-bootstrap": "^1.0@dev || ^0.3"
46+
"phpdocumentor/guides-theme-bootstrap": "^1.0@dev || ^0.3",
47+
"phpdocumentor/guides-theme-rst": "^1.0@dev || ^1.0"
4748
},
4849
"require-dev": {
4950
"ext-dom": "*",

composer.lock

+42-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.subsplit-publish.json

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
"name": "guides-code",
3535
"directory": "packages/guides-code",
3636
"target": "git@github.com:phpDocumentor/guides-code.git"
37+
},
38+
{
39+
"name": "guides-theme-rst",
40+
"directory": "packages/guides-rst-theme",
41+
"target": "git@github.com:phpDocumentor/guides-theme-rst.git"
3742
}
3843
]
3944
}

deptrac.packages.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ deptrac:
4040
CLI:
4141
- "Guides"
4242
- "RST"
43+
- "Markdown"
4344
RST:
4445
- "Guides"
4546
Markdown:
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/docs export-ignore
4+
/tests export-ignore

packages/guides-theme-rst/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vendor/*
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
======================================
2+
Contribute to the phpDocumentor Guides
3+
======================================
4+
5+
Go to the mono-repository
6+
=========================
7+
8+
This project is developed in the mono-repository `phpDocumentor Guides <https://github.com/phpDocumentor/guides>`__.
9+
The repository you are currently in gets auto-created by splitting the mono-repository. You **must not** contribute
10+
to this repository directly but always to the mono-repository linked above.
11+
12+
Create Issues
13+
=============
14+
15+
* If you find something missing or something is wrong in this library, you are welcome to write an issue
16+
describing the problem: `Issues on GitHub <https://github.com/phpDocumentor/guides/issues>`__.
17+
* If you can, please try to fix the problem yourself.
18+
19+
Make changes (create pull requests)
20+
===================================
21+
22+
See the `Contribution chapter <https://github.com/phpDocumentor/guides/tree/main/docs/contributions/index.rst>`__ in the
23+
`Documentation` <https://github.com/phpDocumentor/guides/tree/main/docs/index.rst>`__.

packages/guides-theme-rst/LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2010 Mike van Riel
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

packages/guides-theme-rst/README.rst

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
.. image:: http://poser.pugx.org/phpdocumentor/guides-restructured-text/require/php
3+
:alt: PHP Version Require
4+
:target: https://packagist.org/packages/phpdocumentor/guides-restructured-text
5+
6+
.. image:: http://poser.pugx.org/phpdocumentor/guides-restructured-text/v/stable
7+
:alt: Latest Stable Version
8+
:target: https://packagist.org/packages/phpdocumentor/guides-restructured-text
9+
10+
.. image:: http://poser.pugx.org/phpdocumentor/guides-restructured-text/v/unstable
11+
:alt: Latest Unstable Version
12+
:target: https://packagist.org/packages/phpdocumentor/guides-restructured-text
13+
14+
.. image:: https://poser.pugx.org/phpdocumentor/guides-restructured-text/d/total
15+
:alt: Total Downloads
16+
:target: https://packagist.org/packages/phpdocumentor/guides-restructured-text
17+
18+
.. image:: https://poser.pugx.org/phpdocumentor/guides-restructured-text/d/monthly
19+
:alt: Monthly Downloads
20+
:target: https://packagist.org/packages/phpdocumentor/guides-restructured-text
21+
22+
====================
23+
phpDocumentor Guides
24+
====================
25+
26+
This repository is part of `phpDocumentor's Guides library <https://github.com/phpDocumentor/guides>`__, a framework
27+
designed to take hand-written documentation in code repositories and create an AST (abstract syntax tree) from it.
28+
This AST is then fed to a renderer, which produces the desired output, such as HTML.
29+
30+
The package `phpdocumentor/guides-restructured-text <https://packagist.org/packages/phpdocumentor/guides-restructured-text>`__ adds
31+
`reStructuredText Markup <https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html>`__ support to the
32+
phpDocumentor's Guides library.
33+
34+
:Mono-Repository: https://github.com/phpDocumentor/guides
35+
:Documentation: https://github.com/phpDocumentor/guides/tree/main/docs/index.rst
36+
:Packagist: https://packagist.org/packages/phpdocumentor/guides-restructured-text
37+
:Contribution: https://github.com/phpDocumentor/guides/tree/main/CONTRIBUTING.rst
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "phpdocumentor/guides-theme-rst",
3+
"description": "Adds a reStructuredText theme used to convert Markdown into reStructuredText",
4+
"type": "library",
5+
"license": "MIT",
6+
"homepage": "https://www.phpdoc.org",
7+
"config": {
8+
"sort-packages": true
9+
},
10+
"autoload": {
11+
"psr-4": {
12+
"phpDocumentor\\Guides\\": "src/"
13+
}
14+
},
15+
"autoload-dev": {
16+
"psr-4": {
17+
"phpDocumentor\\Guides\\": [
18+
"tests/unit/"
19+
]
20+
}
21+
},
22+
"minimum-stability": "stable",
23+
"require": {
24+
"php": "^8.1",
25+
"phpdocumentor/guides": "^1.0 || ^2.0"
26+
},
27+
"extra": {
28+
"branch-alias": {
29+
"dev-main": "2.x-dev"
30+
}
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use phpDocumentor\Guides\RstTheme\Renderer\RstRenderer;
6+
use phpDocumentor\Guides\RstTheme\Twig\RstExtension;
7+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
8+
9+
return static function (ContainerConfigurator $container): void {
10+
$container->services()
11+
->defaults()
12+
->autowire()
13+
->autoconfigure()
14+
/*
15+
->load(
16+
'phpDocumentor\\Guides\RstTheme\\NodeRenderers\\Rst\\',
17+
'%vendor_dir%/phpdocumentor/guides-rst-theme/src/RstTheme/NodeRenderers/Rst',
18+
)
19+
->tag('phpdoc.guides.noderenderer.rst')
20+
*/
21+
22+
->set(RstRenderer::class)
23+
->tag(
24+
'phpdoc.renderer.typerenderer',
25+
[
26+
'noderender_tag' => 'phpdoc.guides.noderenderer.rst',
27+
'format' => 'rst',
28+
],
29+
)
30+
31+
->set(RstExtension::class)
32+
->tag('twig.extension')
33+
->autowire();
34+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. code-block:: plaintext
2+
3+
{{ renderRstIndent(node.value|raw, 1)|raw }}
4+
{{ "\n" }}
5+
{{ "\n" }}
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{ "\n" }}
2+
{% if node.isOrdered -%}
3+
{%- for item in node.value -%}
4+
#. {{ renderNode(item.value)|raw }}{{ "\n" }}
5+
{% endfor -%}
6+
{%- else -%}
7+
{%- for item in node.value -%}
8+
* {{ renderNode(item.value)|raw }}{{ "\n" }}
9+
{%- endfor -%}
10+
{%- endif %}
11+
{{ "\n" }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{% set text = renderNode(node.value)|raw -%}
2+
{%- if text|trim %}
3+
{{- text|raw -}}
4+
{% endif -%}
5+
{{ "\n" }}
6+
{{ "\n" }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{ renderRstIndent(renderNode(node.value)|raw, 1)|raw }}
2+
{{ "\n" }}
3+
{{ "\n" }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
====
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\\\\\\\\\n
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\textit{{ '{' }}{{ text|raw }}{{ '}' }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% if type == 'ref' %}
2+
\ref{{ '{' }}{{ url }}{{ '}' }}
3+
{% else %}
4+
\href{{ '{' }}{{ url }}{{ '}' }}{{ '{' }}{{ title }}{{ '}' }}
5+
{% endif %}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\verb|{{ node.value|raw }}|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
~
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\textbf{{ '{' }}{{ text|raw }}{{ '}' }}

packages/guides-theme-rst/resources/template/rst/guides/structure/header/meta.rst.twig

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\{{ type }}{{ '{' }}{{ renderNode(titleNode.value) }}{{ '}' }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*{{- node.value|raw -}}*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{{ "\n" }}
2+
.. figure:: {{ node.url|raw }}
3+
:alt: {{ node.altText|raw }}
4+
{{ "\n" }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%- for child in node.children -%}
2+
{{- renderNode(child)|raw -}}
3+
{%- endfor -%}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{%- if node.url -%}
2+
`{{ node.value|raw }} <{{- node.url -}}>`__
3+
{%- elseif node.targetReference -%}
4+
:doc:`{{ node.value|raw }} <{{- node.targetReference -}}>`
5+
{%- else -%}
6+
{{- node.value -}}
7+
{%- endif -%}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{%- if node.value matches '/`/' -%}
2+
``{{- node.value|raw -}}``
3+
{%- else -%}
4+
`{{- node.value|raw -}}`
5+
{%- endif -%}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{- node.value|raw -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
**{{- node.value|raw -}}**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{%- set renderedContent -%}
2+
{%- for child in node.children -%}
3+
{{- renderNode(child) -}}
4+
{%- endfor -%}
5+
{%- endset -%}
6+
7+
{{- renderedContent | clean_content | raw -}}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ renderRstTitle(node, renderNode(node.value)) }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{%- for document in documents %}
2+
{{- renderNode(document) }}
3+
{%- endfor -%}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{% for childNode in node.children -%}
2+
{{- renderNode(childNode) }}
3+
4+
{% endfor -%}

0 commit comments

Comments
 (0)