-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit dc70aff
Showing
17 changed files
with
1,016 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Knowledge Base project. | ||
* | ||
* Copyright (c) 2015 LIN3S <info@lin3s.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace LIN3S\KnowledgeBase\Builder; | ||
|
||
use LIN3S\KnowledgeBase\Iterator\Interfaces\IteratorInterface; | ||
use LIN3S\KnowledgeBase\Registry\GeneratorRegistry; | ||
|
||
/** | ||
* Document builder class. | ||
* | ||
* @author Gorka Laucirica <gorka@lin3s.com> | ||
* @author Beñat Espiña <bespina@lin3s.com> | ||
*/ | ||
final class DocumentationBuilder | ||
{ | ||
/** | ||
* The iterator. | ||
* | ||
* @var \LIN3S\KnowledgeBase\Iterator\Interfaces\IteratorInterface | ||
*/ | ||
private $iterator; | ||
|
||
/** | ||
* The generator registry. | ||
* | ||
* @var \LIN3S\KnowledgeBase\Registry\GeneratorRegistry | ||
*/ | ||
private $generatorRegistry; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param \LIN3S\KnowledgeBase\Iterator\Interfaces\IteratorInterface $iterator The iterator | ||
* @param \LIN3S\KnowledgeBase\Registry\GeneratorRegistry $generatorRegistry The generator registry | ||
*/ | ||
public function __construct(IteratorInterface $iterator, GeneratorRegistry $generatorRegistry) | ||
{ | ||
$this->iterator = $iterator; | ||
$this->generatorRegistry = $generatorRegistry; | ||
} | ||
|
||
/** | ||
* Index build method. | ||
* | ||
* Its responsibility is to call the parseFile | ||
* and generate methods from generator. | ||
*/ | ||
public function build() | ||
{ | ||
$files = $this->iterator->getFiles(); | ||
$generators = $this->generatorRegistry->generators(); | ||
|
||
foreach ($files as $file) { | ||
foreach ($generators as $generator) { | ||
$generator->parseFile($file); | ||
} | ||
} | ||
|
||
foreach ($generators as $generator) { | ||
$generator->generate(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Knowledge Base project. | ||
* | ||
* Copyright (c) 2015 LIN3S <info@lin3s.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace LIN3S\KnowledgeBase; | ||
|
||
use LIN3S\KnowledgeBase\Templating\TemplateInterface; | ||
|
||
/** | ||
* Configuration class. | ||
* | ||
* @author Gorka Laucirica <gorka@lin3s.com> | ||
* @author Beñat Espiña <bespina@lin3s.com> | ||
*/ | ||
final class Configuration | ||
{ | ||
/** | ||
* The docs path. | ||
* | ||
* @var string | ||
*/ | ||
private $docsPath; | ||
|
||
/** | ||
* The build path. | ||
* | ||
* @var string | ||
*/ | ||
private $buildPath; | ||
|
||
/** | ||
* The template. | ||
* | ||
* @var \LIN3S\KnowledgeBase\Templating\TemplateInterface | ||
*/ | ||
private $template; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param string $docsPath Path where the docs are located | ||
* @param string $buildPath Path where the generated docs will be placed | ||
* @param \LIN3S\KnowledgeBase\Templating\TemplateInterface $template The template | ||
* @param string $assetsBaseUrl Base url templates will use to find assets | ||
*/ | ||
public function __construct($docsPath, $buildPath, TemplateInterface $template, $assetsBaseUrl = '/templates') | ||
{ | ||
$this->docsPath = $docsPath; | ||
$this->buildPath = $buildPath; | ||
$this->template = $template; | ||
$this->assetsBaseUrl = $assetsBaseUrl; | ||
} | ||
|
||
/** | ||
* Gets the build path. | ||
* | ||
* @return string | ||
*/ | ||
public function buildPath() | ||
{ | ||
return $this->buildPath; | ||
} | ||
|
||
/** | ||
* Gets the docs path. | ||
* | ||
* @return string | ||
*/ | ||
public function docsPath() | ||
{ | ||
return $this->docsPath; | ||
} | ||
|
||
/** | ||
* The template. | ||
* | ||
* @return \LIN3S\KnowledgeBase\Templating\TemplateInterface | ||
*/ | ||
public function template() | ||
{ | ||
return $this->template; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Knowledge Base project. | ||
* | ||
* Copyright (c) 2015 LIN3S <info@lin3s.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace LIN3S\KnowledgeBase\File; | ||
|
||
use LIN3S\KnowledgeBase\File\Interfaces\FileInterface; | ||
|
||
/** | ||
* File abstract class. | ||
* | ||
* @author Gorka Laucirica <gorka@lin3s.com> | ||
* @author Beñat Espiña <bespina@lin3s.com> | ||
*/ | ||
abstract class File implements FileInterface | ||
{ | ||
/** | ||
* The content. | ||
* | ||
* @var string | ||
*/ | ||
protected $content; | ||
|
||
/** | ||
* The name. | ||
* | ||
* @var string | ||
*/ | ||
protected $name; | ||
|
||
/** | ||
* The path. | ||
* | ||
* @var string | ||
*/ | ||
protected $path; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param string $name The name | ||
* @param string $path The path | ||
* @param string $content The content | ||
*/ | ||
public function __construct($name, $path = __DIR__, $content = null) | ||
{ | ||
$this->name = $name; | ||
$this->path = $path; | ||
$this->content = $content; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getContent() | ||
{ | ||
return $this->content; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPath() | ||
{ | ||
return $this->path; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
abstract public function getExtension(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Knowledge Base project. | ||
* | ||
* Copyright (c) 2015 LIN3S <info@lin3s.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace LIN3S\KnowledgeBase\File\Interfaces; | ||
|
||
/** | ||
* File interface. | ||
* | ||
* @author Gorka Laucirica <gorka@lin3s.com> | ||
* @author Beñat Espiña <bespina@lin3s.com> | ||
*/ | ||
interface FileInterface | ||
{ | ||
/** | ||
* Returns file name without path nor extension. | ||
* | ||
* @return string | ||
*/ | ||
public function getName(); | ||
|
||
/** | ||
* Returns raw file content. | ||
* | ||
* @return string | ||
*/ | ||
public function getContent(); | ||
|
||
/** | ||
* Returns relative to docs folder file path without filename nor extension. | ||
* | ||
* @return string | ||
*/ | ||
public function getPath(); | ||
|
||
/** | ||
* Returns file extension without the dot. For example (md) | ||
* | ||
* @return string | ||
*/ | ||
public function getExtension(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Knowledge Base project. | ||
* | ||
* Copyright (c) 2015 LIN3S <info@lin3s.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace LIN3S\KnowledgeBase\File; | ||
|
||
/** | ||
* Markdown file class. | ||
* | ||
* @author Beñat Espiña <bespina@lin3s.com> | ||
*/ | ||
final class MarkdownFile extends File | ||
{ | ||
const EXTENSION = 'md'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getExtension() | ||
{ | ||
return self::EXTENSION; | ||
} | ||
} |
Oops, something went wrong.