Update website

This commit is contained in:
Guilhem Lavaux 2024-11-19 08:02:04 +01:00
parent 4413528994
commit 1d90fbf296
6865 changed files with 1091082 additions and 0 deletions

View file

@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace Doctrine\RST\LaTeX\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 build relative url for %s', $data));
}
return $parser->getNodeFactory()->createImageNode($url, $options);
}
}

View file

@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace Doctrine\RST\LaTeX\Directives;
use Doctrine\RST\Directives\Directive;
use Doctrine\RST\Nodes\Node;
use Doctrine\RST\Parser;
/**
* Marks the document as LaTeX main
*/
final class LaTeXMain extends Directive
{
public function getName(): string
{
return 'latex-main';
}
/** @param string[] $options */
public function processNode(
Parser $parser,
string $variable,
string $data,
array $options
): ?Node {
return $parser->getNodeFactory()->createMainNode();
}
}

View file

@ -0,0 +1,48 @@
<?php
declare(strict_types=1);
namespace Doctrine\RST\LaTeX\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);
}
}

View file

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Doctrine\RST\LaTeX\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 {
}
}

View file

@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace Doctrine\RST\LaTeX\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();
$document->addHeaderNode(
$parser->getNodeFactory()->createRawNode('\title{' . $data . '}')
);
if ($node === null) {
return;
}
$document->addNode($node);
}
}

View file

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Doctrine\RST\LaTeX\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));
}
}

View file

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace Doctrine\RST\LaTeX\Directives;
use Doctrine\RST\Directives\SubDirective;
use Doctrine\RST\Nodes\Node;
use Doctrine\RST\Parser;
/**
* Wraps a sub document in a div with a given class
*/
final class Wrap extends SubDirective
{
/** @var string */
private $class;
public function __construct(string $class)
{
$this->class = $class;
}
public function getName(): string
{
return $this->class;
}
/** @param string[] $options */
public function processSub(
Parser $parser,
?Node $document,
string $variable,
string $data,
array $options
): ?Node {
return $document;
}
}