Update website
This commit is contained in:
parent
4413528994
commit
1d90fbf296
6865 changed files with 1091082 additions and 0 deletions
43
vendor/doctrine/rst-parser/lib/Meta/CachedMetasLoader.php
vendored
Normal file
43
vendor/doctrine/rst-parser/lib/Meta/CachedMetasLoader.php
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\Meta;
|
||||
|
||||
use LogicException;
|
||||
|
||||
use function file_exists;
|
||||
use function file_get_contents;
|
||||
use function file_put_contents;
|
||||
use function serialize;
|
||||
use function sprintf;
|
||||
use function unserialize;
|
||||
|
||||
final class CachedMetasLoader
|
||||
{
|
||||
public function loadCachedMetaEntries(string $targetDirectory, Metas $metas): void
|
||||
{
|
||||
$metaCachePath = $this->getMetaCachePath($targetDirectory);
|
||||
if (! file_exists($metaCachePath)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$contents = file_get_contents($metaCachePath);
|
||||
|
||||
if ($contents === false) {
|
||||
throw new LogicException(sprintf('Could not load file "%s"', $contents));
|
||||
}
|
||||
|
||||
$metas->setMetaEntries(unserialize($contents));
|
||||
}
|
||||
|
||||
public function cacheMetaEntries(string $targetDirectory, Metas $metas): void
|
||||
{
|
||||
file_put_contents($this->getMetaCachePath($targetDirectory), serialize($metas->getAll()));
|
||||
}
|
||||
|
||||
private function getMetaCachePath(string $targetDirectory): string
|
||||
{
|
||||
return $targetDirectory . '/metas.php';
|
||||
}
|
||||
}
|
206
vendor/doctrine/rst-parser/lib/Meta/MetaEntry.php
vendored
Normal file
206
vendor/doctrine/rst-parser/lib/Meta/MetaEntry.php
vendored
Normal file
|
@ -0,0 +1,206 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\Meta;
|
||||
|
||||
use Doctrine\RST\Environment;
|
||||
use LogicException;
|
||||
|
||||
use function array_merge;
|
||||
use function array_search;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use function is_string;
|
||||
use function sprintf;
|
||||
|
||||
class MetaEntry
|
||||
{
|
||||
/** @var string */
|
||||
private $file;
|
||||
|
||||
/** @var string */
|
||||
private $url;
|
||||
|
||||
/** @var string */
|
||||
private $title;
|
||||
|
||||
/** @var string[][]|string[][][] */
|
||||
private $titles;
|
||||
|
||||
/** @var mixed[][] */
|
||||
private $tocs;
|
||||
|
||||
/** @var int */
|
||||
private $mtime;
|
||||
|
||||
/** @var string[] */
|
||||
private $depends;
|
||||
|
||||
/** @var string[] */
|
||||
private $resolvedDependencies = [];
|
||||
|
||||
/** @var string[] */
|
||||
private $links;
|
||||
|
||||
/** @var string|null */
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
* @param string[][]|string[][][] $titles
|
||||
* @param mixed[][] $tocs
|
||||
* @param string[] $depends
|
||||
* @param string[] $links
|
||||
*/
|
||||
public function __construct(
|
||||
string $file,
|
||||
string $url,
|
||||
string $title,
|
||||
array $titles,
|
||||
array $tocs,
|
||||
array $depends,
|
||||
array $links,
|
||||
int $mtime
|
||||
) {
|
||||
$this->file = $file;
|
||||
$this->url = $url;
|
||||
$this->title = $title;
|
||||
$this->titles = $titles;
|
||||
$this->tocs = $tocs;
|
||||
$this->depends = $depends;
|
||||
$this->links = $links;
|
||||
$this->mtime = $mtime;
|
||||
}
|
||||
|
||||
public function getFile(): string
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
public function getUrl(): string
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/** @return string[][]|string[][][] */
|
||||
public function getTitles(): array
|
||||
{
|
||||
return $this->titles;
|
||||
}
|
||||
|
||||
public function hasTitle(string $text): bool
|
||||
{
|
||||
$titles = $this->getAllTitles();
|
||||
|
||||
$text = Environment::slugify($text);
|
||||
|
||||
foreach ($titles as $title) {
|
||||
if ($text === Environment::slugify($title)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @return mixed[][] */
|
||||
public function getTocs(): array
|
||||
{
|
||||
return $this->tocs;
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
public function getDepends(): array
|
||||
{
|
||||
return $this->depends;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call to replace a dependency with the resolved, real filename.
|
||||
*/
|
||||
public function resolveDependency(string $originalDependency, ?string $newDependency): void
|
||||
{
|
||||
if ($newDependency === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we only need to resolve a dependency one time
|
||||
if (in_array($originalDependency, $this->resolvedDependencies, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$key = array_search($originalDependency, $this->depends, true);
|
||||
|
||||
if ($key === false) {
|
||||
throw new LogicException(sprintf('Could not find dependency "%s" in MetaEntry for "%s"', $originalDependency, $this->file));
|
||||
}
|
||||
|
||||
$this->depends[$key] = $newDependency;
|
||||
$this->resolvedDependencies[] = $originalDependency;
|
||||
}
|
||||
|
||||
public function removeDependency(string $dependency): void
|
||||
{
|
||||
$key = array_search($dependency, $this->depends, true);
|
||||
|
||||
if ($key === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
unset($this->depends[$key]);
|
||||
}
|
||||
|
||||
/** @return string[] */
|
||||
public function getLinks(): array
|
||||
{
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
public function getMtime(): int
|
||||
{
|
||||
return $this->mtime;
|
||||
}
|
||||
|
||||
public function setParent(string $parent): void
|
||||
{
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
public function getParent(): ?string
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[]|string[][]|null $entryTitles
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function getAllTitles(?array $entryTitles = null): array
|
||||
{
|
||||
if ($entryTitles === null) {
|
||||
$entryTitles = $this->titles;
|
||||
}
|
||||
|
||||
$titles = [];
|
||||
|
||||
foreach ($entryTitles as $title) {
|
||||
if (is_string($title[0])) {
|
||||
$titles[] = $title[0];
|
||||
}
|
||||
|
||||
if (! is_array($title[1])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$titles = array_merge($titles, $this->getAllTitles($title[1]));
|
||||
}
|
||||
|
||||
return $titles;
|
||||
}
|
||||
}
|
128
vendor/doctrine/rst-parser/lib/Meta/Metas.php
vendored
Normal file
128
vendor/doctrine/rst-parser/lib/Meta/Metas.php
vendored
Normal file
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Doctrine\RST\Meta;
|
||||
|
||||
use Doctrine\RST\Environment;
|
||||
|
||||
use function strtolower;
|
||||
|
||||
class Metas
|
||||
{
|
||||
/** @var MetaEntry[] */
|
||||
private $entries = [];
|
||||
|
||||
/** @var string[] */
|
||||
private $parents = [];
|
||||
|
||||
/** @param MetaEntry[] $entries */
|
||||
public function __construct(array $entries = [])
|
||||
{
|
||||
$this->entries = $entries;
|
||||
}
|
||||
|
||||
public function findLinkMetaEntry(string $link): ?MetaEntry
|
||||
{
|
||||
foreach ($this->entries as $entry) {
|
||||
if ($this->doesLinkExist($entry->getLinks(), $link)) {
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->findByTitle($link);
|
||||
}
|
||||
|
||||
/** @return MetaEntry[] */
|
||||
public function getAll(): array
|
||||
{
|
||||
return $this->entries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[][] $titles
|
||||
* @param mixed[][] $tocs
|
||||
* @param string[] $depends
|
||||
* @param string[] $links
|
||||
*/
|
||||
public function set(
|
||||
string $file,
|
||||
string $url,
|
||||
string $title,
|
||||
array $titles,
|
||||
array $tocs,
|
||||
int $mtime,
|
||||
array $depends,
|
||||
array $links
|
||||
): void {
|
||||
foreach ($tocs as $toc) {
|
||||
foreach ($toc as $child) {
|
||||
$this->parents[$child] = $file;
|
||||
|
||||
if (! isset($this->entries[$child])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->entries[$child]->setParent($file);
|
||||
}
|
||||
}
|
||||
|
||||
$this->entries[$file] = new MetaEntry(
|
||||
$file,
|
||||
$url,
|
||||
$title,
|
||||
$titles,
|
||||
$tocs,
|
||||
$depends,
|
||||
$links,
|
||||
$mtime
|
||||
);
|
||||
|
||||
if (! isset($this->parents[$file])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->entries[$file]->setParent($this->parents[$file]);
|
||||
}
|
||||
|
||||
public function get(string $url): ?MetaEntry
|
||||
{
|
||||
if (isset($this->entries[$url])) {
|
||||
return $this->entries[$url];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @param MetaEntry[] $metaEntries */
|
||||
public function setMetaEntries(array $metaEntries): void
|
||||
{
|
||||
$this->entries = $metaEntries;
|
||||
}
|
||||
|
||||
/** @param string[] $links */
|
||||
private function doesLinkExist(array $links, string $link): bool
|
||||
{
|
||||
foreach ($links as $name => $url) {
|
||||
if ($name === strtolower($link)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private function findByTitle(string $text): ?MetaEntry
|
||||
{
|
||||
$text = Environment::slugify($text);
|
||||
|
||||
// try to lookup the document reference by title
|
||||
foreach ($this->entries as $entry) {
|
||||
if ($entry->hasTitle($text)) {
|
||||
return $entry;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue