Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
71
vendor/doctrine/rst-parser/lib/HTML/Directives/ClassDirective.php
vendored
Normal file
71
vendor/doctrine/rst-parser/lib/HTML/Directives/ClassDirective.php
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\HTML\Directives;
|
||||
|
||||
use Doctrine\RST\Directives\SubDirective;
|
||||
use Doctrine\RST\Environment;
|
||||
use Doctrine\RST\Nodes\DocumentNode;
|
||||
use Doctrine\RST\Nodes\Node;
|
||||
use Doctrine\RST\Parser;
|
||||
|
||||
use function array_map;
|
||||
use function explode;
|
||||
|
||||
final class ClassDirective extends SubDirective
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'class';
|
||||
}
|
||||
|
||||
/** @param string[] $options */
|
||||
public function processSub(
|
||||
Parser $parser,
|
||||
?Node $document,
|
||||
string $variable,
|
||||
string $data,
|
||||
array $options
|
||||
): ?Node {
|
||||
if ($document === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$classes = explode(' ', $data);
|
||||
|
||||
$normalizedClasses = array_map(static function (string $class): string {
|
||||
return Environment::slugify($class);
|
||||
}, $classes);
|
||||
|
||||
$document->setClasses($normalizedClasses);
|
||||
|
||||
if ($document instanceof DocumentNode) {
|
||||
$this->setNodesClasses($document->getNodes(), $classes);
|
||||
}
|
||||
|
||||
return $document;
|
||||
}
|
||||
|
||||
public function appliesToNonBlockContent(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Node[] $nodes
|
||||
* @param string[] $classes
|
||||
*/
|
||||
private function setNodesClasses(array $nodes, array $classes): void
|
||||
{
|
||||
foreach ($nodes as $node) {
|
||||
$node->setClasses($classes);
|
||||
|
||||
if (! ($node instanceof DocumentNode)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->setNodesClasses($node->getNodes(), $classes);
|
||||
}
|
||||
}
|
||||
}
|
33
vendor/doctrine/rst-parser/lib/HTML/Directives/Div.php
vendored
Normal file
33
vendor/doctrine/rst-parser/lib/HTML/Directives/Div.php
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\HTML\Directives;
|
||||
|
||||
use Doctrine\RST\Directives\SubDirective;
|
||||
use Doctrine\RST\Nodes\Node;
|
||||
use Doctrine\RST\Parser;
|
||||
|
||||
/**
|
||||
* Divs a sub document in a div with a given class
|
||||
*/
|
||||
final class Div extends SubDirective
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'div';
|
||||
}
|
||||
|
||||
/** @param string[] $options */
|
||||
public function processSub(
|
||||
Parser $parser,
|
||||
?Node $document,
|
||||
string $variable,
|
||||
string $data,
|
||||
array $options
|
||||
): ?Node {
|
||||
$divOpen = $parser->renderTemplate('div-open.html.twig', ['class' => $data]);
|
||||
|
||||
return $parser->getNodeFactory()->createWrapperNode($document, $divOpen, '</div>');
|
||||
}
|
||||
}
|
53
vendor/doctrine/rst-parser/lib/HTML/Directives/Figure.php
vendored
Normal file
53
vendor/doctrine/rst-parser/lib/HTML/Directives/Figure.php
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\HTML\Directives;
|
||||
|
||||
use Doctrine\RST\Directives\SubDirective;
|
||||
use Doctrine\RST\Nodes\Node;
|
||||
use Doctrine\RST\Parser;
|
||||
use Exception;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Renders an image, example :
|
||||
*
|
||||
* .. figure:: image.jpg
|
||||
* :width: 100
|
||||
* :title: An image
|
||||
*
|
||||
* Here is an awesome caption
|
||||
*/
|
||||
final class Figure extends SubDirective
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'figure';
|
||||
}
|
||||
|
||||
/** @param string[] $options */
|
||||
public function processSub(
|
||||
Parser $parser,
|
||||
?Node $document,
|
||||
string $variable,
|
||||
string $data,
|
||||
array $options
|
||||
): ?Node {
|
||||
$environment = $parser->getEnvironment();
|
||||
|
||||
$url = $environment->relativeUrl($data);
|
||||
|
||||
if ($url === null) {
|
||||
throw new Exception(sprintf('Could not get relative url for %s', $data));
|
||||
}
|
||||
|
||||
$nodeFactory = $parser->getNodeFactory();
|
||||
|
||||
return $parser->getNodeFactory()->createFigureNode(
|
||||
$nodeFactory->createImageNode($url, $options),
|
||||
$document
|
||||
);
|
||||
}
|
||||
}
|
45
vendor/doctrine/rst-parser/lib/HTML/Directives/Image.php
vendored
Normal file
45
vendor/doctrine/rst-parser/lib/HTML/Directives/Image.php
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\HTML\Directives;
|
||||
|
||||
use Doctrine\RST\Directives\Directive;
|
||||
use Doctrine\RST\Nodes\Node;
|
||||
use Doctrine\RST\Parser;
|
||||
use Exception;
|
||||
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* Renders an image, example :
|
||||
*
|
||||
* .. image:: image.jpg
|
||||
* :width: 100
|
||||
* :title: An image
|
||||
*/
|
||||
final class Image extends Directive
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'image';
|
||||
}
|
||||
|
||||
/** @param string[] $options */
|
||||
public function processNode(
|
||||
Parser $parser,
|
||||
string $variable,
|
||||
string $data,
|
||||
array $options
|
||||
): ?Node {
|
||||
$environment = $parser->getEnvironment();
|
||||
|
||||
$url = $environment->relativeUrl($data);
|
||||
|
||||
if ($url === null) {
|
||||
throw new Exception(sprintf('Could not get relative url for %s', $data));
|
||||
}
|
||||
|
||||
return $parser->getNodeFactory()->createImageNode($url, $options);
|
||||
}
|
||||
}
|
48
vendor/doctrine/rst-parser/lib/HTML/Directives/Meta.php
vendored
Normal file
48
vendor/doctrine/rst-parser/lib/HTML/Directives/Meta.php
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\HTML\Directives;
|
||||
|
||||
use Doctrine\RST\Directives\Directive;
|
||||
use Doctrine\RST\Nodes\Node;
|
||||
use Doctrine\RST\Parser;
|
||||
|
||||
/**
|
||||
* Add a meta information:
|
||||
*
|
||||
* .. meta::
|
||||
* :key: value
|
||||
*/
|
||||
final class Meta extends Directive
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'meta';
|
||||
}
|
||||
|
||||
/** @param string[] $options */
|
||||
public function process(
|
||||
Parser $parser,
|
||||
?Node $node,
|
||||
string $variable,
|
||||
string $data,
|
||||
array $options
|
||||
): void {
|
||||
$document = $parser->getDocument();
|
||||
|
||||
$nodeFactory = $parser->getNodeFactory();
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
$meta = $nodeFactory->createMetaNode($key, $value);
|
||||
|
||||
$document->addHeaderNode($meta);
|
||||
}
|
||||
|
||||
if ($node === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$document->addNode($node);
|
||||
}
|
||||
}
|
40
vendor/doctrine/rst-parser/lib/HTML/Directives/Stylesheet.php
vendored
Normal file
40
vendor/doctrine/rst-parser/lib/HTML/Directives/Stylesheet.php
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\HTML\Directives;
|
||||
|
||||
use Doctrine\RST\Directives\Directive;
|
||||
use Doctrine\RST\Nodes\Node;
|
||||
use Doctrine\RST\Parser;
|
||||
|
||||
/**
|
||||
* Adds a stylesheet to a document, example:
|
||||
*
|
||||
* .. stylesheet:: style.css
|
||||
*/
|
||||
final class Stylesheet extends Directive
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'stylesheet';
|
||||
}
|
||||
|
||||
/** @param string[] $options */
|
||||
public function process(
|
||||
Parser $parser,
|
||||
?Node $node,
|
||||
string $variable,
|
||||
string $data,
|
||||
array $options
|
||||
): void {
|
||||
$document = $parser->getDocument();
|
||||
$document->addCss($data);
|
||||
|
||||
if ($node === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$document->addNode($node);
|
||||
}
|
||||
}
|
45
vendor/doctrine/rst-parser/lib/HTML/Directives/Title.php
vendored
Normal file
45
vendor/doctrine/rst-parser/lib/HTML/Directives/Title.php
vendored
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\HTML\Directives;
|
||||
|
||||
use Doctrine\RST\Directives\Directive;
|
||||
use Doctrine\RST\Nodes\Node;
|
||||
use Doctrine\RST\Parser;
|
||||
|
||||
/**
|
||||
* Add a meta title to the document
|
||||
*
|
||||
* .. title:: Page title
|
||||
*/
|
||||
final class Title extends Directive
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'title';
|
||||
}
|
||||
|
||||
/** @param string[] $options */
|
||||
public function process(
|
||||
Parser $parser,
|
||||
?Node $node,
|
||||
string $variable,
|
||||
string $data,
|
||||
array $options
|
||||
): void {
|
||||
$document = $parser->getDocument();
|
||||
|
||||
$title = $parser->renderTemplate('title.html.twig', ['title' => $data]);
|
||||
|
||||
$document->addHeaderNode(
|
||||
$parser->getNodeFactory()->createRawNode($title)
|
||||
);
|
||||
|
||||
if ($node === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$document->addNode($node);
|
||||
}
|
||||
}
|
33
vendor/doctrine/rst-parser/lib/HTML/Directives/Url.php
vendored
Normal file
33
vendor/doctrine/rst-parser/lib/HTML/Directives/Url.php
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\HTML\Directives;
|
||||
|
||||
use Doctrine\RST\Directives\Directive;
|
||||
use Doctrine\RST\Parser;
|
||||
|
||||
use function trim;
|
||||
|
||||
/**
|
||||
* Sets the document URL
|
||||
*/
|
||||
final class Url extends Directive
|
||||
{
|
||||
public function getName(): string
|
||||
{
|
||||
return 'url';
|
||||
}
|
||||
|
||||
/** @param string[] $options */
|
||||
public function processAction(
|
||||
Parser $parser,
|
||||
string $variable,
|
||||
string $data,
|
||||
array $options
|
||||
): void {
|
||||
$environment = $parser->getEnvironment();
|
||||
|
||||
$environment->setUrl(trim($data));
|
||||
}
|
||||
}
|
66
vendor/doctrine/rst-parser/lib/HTML/Directives/Wrap.php
vendored
Normal file
66
vendor/doctrine/rst-parser/lib/HTML/Directives/Wrap.php
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\HTML\Directives;
|
||||
|
||||
use Doctrine\RST\Directives\SubDirective;
|
||||
use Doctrine\RST\Nodes\Node;
|
||||
use Doctrine\RST\Parser;
|
||||
use RuntimeException;
|
||||
|
||||
use function uniqid;
|
||||
|
||||
/**
|
||||
* Wraps a sub document in a div with a given class
|
||||
*/
|
||||
final class Wrap extends SubDirective
|
||||
{
|
||||
/** @var string */
|
||||
private $class;
|
||||
|
||||
/** @var bool */
|
||||
private $uniqid;
|
||||
|
||||
public function __construct(string $class, bool $uniqid = false)
|
||||
{
|
||||
$this->class = $class;
|
||||
$this->uniqid = $uniqid;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
/** @param string[] $options */
|
||||
public function processSub(
|
||||
Parser $parser,
|
||||
?Node $document,
|
||||
string $variable,
|
||||
string $data,
|
||||
array $options
|
||||
): ?Node {
|
||||
// if there is a "Wrap" directive (e.g. a note::), blank content is unexpected
|
||||
if ($document === null) {
|
||||
throw new RuntimeException('Content expected, none found.');
|
||||
}
|
||||
|
||||
if ($this->uniqid) {
|
||||
$id = uniqid($this->class);
|
||||
} else {
|
||||
$id = '';
|
||||
}
|
||||
|
||||
$divOpen = $parser->renderTemplate('div-open.html.twig', [
|
||||
'id' => $id,
|
||||
'class' => $this->class,
|
||||
]);
|
||||
|
||||
return $parser->getNodeFactory()->createWrapperNode(
|
||||
$document,
|
||||
$divOpen,
|
||||
'</div>'
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue