mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-20 20:34:25 +02:00
doc: Support header-less sections
This commit is contained in:
parent
82d36e11cc
commit
f1a63a36f5
@ -145,11 +145,11 @@ class DocParser
|
|||||||
public function getDocTree()
|
public function getDocTree()
|
||||||
{
|
{
|
||||||
$tree = new SimpleTree();
|
$tree = new SimpleTree();
|
||||||
$stack = new SplStack();
|
|
||||||
foreach ($this->docIterator as $fileInfo) {
|
foreach ($this->docIterator as $fileInfo) {
|
||||||
/** @var $fileInfo \SplFileInfo */
|
/** @var $fileInfo \SplFileInfo */
|
||||||
$file = $fileInfo->openFile();
|
$file = $fileInfo->openFile();
|
||||||
$lastLine = null;
|
$lastLine = null;
|
||||||
|
$stack = new SplStack();
|
||||||
$cachingIterator = new CachingIterator($file, CachingIterator::TOSTRING_USE_CURRENT);
|
$cachingIterator = new CachingIterator($file, CachingIterator::TOSTRING_USE_CURRENT);
|
||||||
for ($cachingIterator->rewind(); $line = $cachingIterator->valid(); $cachingIterator->next()) {
|
for ($cachingIterator->rewind(); $line = $cachingIterator->valid(); $cachingIterator->next()) {
|
||||||
$fileIterator = $cachingIterator->getInnerIterator();
|
$fileIterator = $cachingIterator->getInnerIterator();
|
||||||
@ -195,7 +195,20 @@ class DocParser
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($stack->isEmpty()) {
|
if ($stack->isEmpty()) {
|
||||||
throw new LogicException('Heading required');
|
$title = ucfirst($file->getBasename('.' . pathinfo($file->getFilename(), PATHINFO_EXTENSION)));
|
||||||
|
$id = $title;
|
||||||
|
if ($tree->getNode($id) !== null) {
|
||||||
|
$id = uniqid($id);
|
||||||
|
}
|
||||||
|
$section = new DocSection();
|
||||||
|
$section
|
||||||
|
->setId($id)
|
||||||
|
->setTitle($title)
|
||||||
|
->setLevel(1)
|
||||||
|
->setNoFollow(true);
|
||||||
|
$section->setChapter($section);
|
||||||
|
$tree->addChild($section);
|
||||||
|
$stack->push($section);
|
||||||
}
|
}
|
||||||
$stack->top()->appendContent($line);
|
$stack->top()->appendContent($line);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user