forked from oxycoder/laravel-apidoc-generator
-
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
Showing
79 changed files
with
9,310 additions
and
59 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 |
---|---|---|
@@ -1,26 +1,28 @@ | ||
{ | ||
"name": "mpociot/laravel-apidoc-generator", | ||
"name": "oxycoder/laravel-apidoc-generator", | ||
"license": "MIT", | ||
"description": "Generate beautiful API documentation from your Laravel application", | ||
"keywords": [ | ||
"API", | ||
"Documentation", | ||
"Laravel" | ||
], | ||
"homepage": "http://github.com/mpociot/laravel-apidoc-generator", | ||
"homepage": "http://github.com/oxycoder/laravel-apidoc-generator", | ||
"authors": [ | ||
{ | ||
"name": "Marcel Pociot", | ||
"name": "Tung", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.5.0", | ||
"fzaninotto/faker": "~1.0", | ||
"laravel/framework": "~5.4", | ||
"mpociot/documentarian": "^0.2.0", | ||
"mpociot/reflection-docblock": "^1.0", | ||
"ramsey/uuid": "^3.0" | ||
"ramsey/uuid": "^3.0", | ||
"mnapoli/front-yaml": "^1.5", | ||
"windwalker/renderer": "3.*", | ||
"mnapoli/silly": "~1.0", | ||
"illuminate/view": "5.*" | ||
}, | ||
"require-dev": { | ||
"orchestra/testbench": "~3.0", | ||
|
@@ -29,19 +31,22 @@ | |
"mockery/mockery": "^0.9.5" | ||
}, | ||
"autoload": { | ||
"files": [ | ||
"src/Oxycoder/ApiDoc/Documentarian/helpers.php" | ||
], | ||
"psr-0": { | ||
"Mpociot\\ApiDoc": "src/" | ||
"Oxycoder\\ApiDoc": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Mpociot\\ApiDoc\\Tests\\": "tests/" | ||
"Oxycoder\\ApiDoc\\Tests\\": "tests/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Mpociot\\ApiDoc\\ApiDocGeneratorServiceProvider" | ||
"Oxycoder\\ApiDoc\\ApiDocGeneratorServiceProvider" | ||
] | ||
} | ||
} | ||
|
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
14 changes: 7 additions & 7 deletions
14
...ApiDoc/Commands/GenerateDocumentation.php → ...ApiDoc/Commands/GenerateDocumentation.php
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
4 changes: 2 additions & 2 deletions
4
...t/ApiDoc/Commands/UpdateDocumentation.php → ...r/ApiDoc/Commands/UpdateDocumentation.php
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
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,104 @@ | ||
<?php | ||
|
||
namespace Oxycoder\Documentarian; | ||
|
||
use Mni\FrontYAML\Parser; | ||
use Windwalker\Renderer\BladeRenderer; | ||
|
||
/** | ||
* Class Documentarian | ||
* @package Mpociot\Documentarian | ||
*/ | ||
class Documentarian | ||
{ | ||
|
||
/** | ||
* Returns a config value | ||
* | ||
* @param string $key | ||
* @return mixed | ||
*/ | ||
public function config($folder, $key = null) | ||
{ | ||
$config = include($folder . '/source/config.php'); | ||
|
||
return is_null($key) ? $config : array_get($config, $key); | ||
} | ||
|
||
/** | ||
* Create a new API documentation folder and copy all needed files/stubs | ||
* | ||
* @param $folder | ||
*/ | ||
public function create($folder) | ||
{ | ||
$folder = $folder . '/source'; | ||
if (!is_dir($folder)) { | ||
mkdir($folder, 0777, true); | ||
mkdir($folder . '/../css'); | ||
mkdir($folder . '/../js'); | ||
mkdir($folder . '/includes'); | ||
mkdir($folder . '/assets'); | ||
} | ||
|
||
// copy stub files | ||
copy(__DIR__ . '/../../resources/assets/stubs/index.md', $folder . '/index.md'); | ||
copy(__DIR__ . '/../../resources/assets/stubs/gitignore.stub', $folder . '/.gitignore'); | ||
copy(__DIR__ . '/../../resources/assets/stubs/includes/_errors.md', $folder . '/includes/_errors.md'); | ||
copy(__DIR__ . '/../../resources/assets/stubs/package.json', $folder . '/package.json'); | ||
copy(__DIR__ . '/../../resources/assets/stubs/gulpfile.js', $folder . '/gulpfile.js'); | ||
copy(__DIR__ . '/../../resources/assets/stubs/config.php', $folder . '/config.php'); | ||
copy(__DIR__ . '/../../resources/assets/stubs/js/all.js', $folder . '/../js/all.js'); | ||
copy(__DIR__ . '/../../resources/assets/stubs/css/style.css', $folder . '/../css/style.css'); | ||
|
||
// copy resources | ||
rcopy(__DIR__ . '/../../resources/assets/images/', $folder . '/assets/images'); | ||
rcopy(__DIR__ . '/../../resources/assets/js/', $folder . '/assets/js'); | ||
rcopy(__DIR__ . '/../../resources/assets/stylus/', $folder . '/assets/stylus'); | ||
} | ||
|
||
/** | ||
* Generate the API documentation using the markdown and include files | ||
* | ||
* @param $folder | ||
* @return false|null | ||
*/ | ||
public function generate($folder) | ||
{ | ||
$source_dir = $folder . '/source'; | ||
|
||
if (!is_dir($source_dir)) { | ||
return false; | ||
} | ||
|
||
$parser = new Parser(); | ||
|
||
$document = $parser->parse(file_get_contents($source_dir . '/index.md')); | ||
|
||
$frontmatter = $document->getYAML(); | ||
$html = $document->getContent(); | ||
|
||
$renderer = new BladeRenderer([__DIR__ . '/../../resources/views'], ['cache_path' => $source_dir . '/_tmp']); | ||
|
||
// Parse and include optional include markdown files | ||
if (isset($frontmatter['includes'])) { | ||
foreach ($frontmatter['includes'] as $include) { | ||
if (file_exists($include_file = $source_dir . '/includes/_' . $include . '.md')) { | ||
$document = $parser->parse(file_get_contents($include_file)); | ||
$html .= $document->getContent(); | ||
} | ||
} | ||
} | ||
|
||
$output = $renderer->render('index', [ | ||
'page' => $frontmatter, | ||
'content' => $html | ||
]); | ||
|
||
file_put_contents($folder . '/index.html', $output); | ||
|
||
// Copy assets | ||
rcopy($source_dir . '/assets/images/', $folder . '/images'); | ||
rcopy($source_dir . '/assets/stylus/fonts/', $folder . '/css/fonts'); | ||
} | ||
} |
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,66 @@ | ||
<?php | ||
/** | ||
* Output the given text to the console. | ||
* | ||
* @param string $output | ||
* @return void | ||
*/ | ||
if (!function_exists('info')) { | ||
function info($output) | ||
{ | ||
output('<info>' . $output . '</info>'); | ||
} | ||
} | ||
|
||
/** | ||
* Output the given text to the console. | ||
* | ||
* @param string $output | ||
* @return void | ||
*/ | ||
if (!function_exists('output')) { | ||
function output($output) | ||
{ | ||
if (isset($_ENV['APP_ENV']) && $_ENV['APP_ENV'] == 'testing') { | ||
return; | ||
} | ||
(new Symfony\Component\Console\Output\ConsoleOutput)->writeln($output); | ||
} | ||
} | ||
|
||
/** | ||
* Recursively copy files from one directory to another | ||
* | ||
* @param String $src - Source of files being moved | ||
* @param String $dest - Destination of files being moved | ||
* @return bool | ||
*/ | ||
|
||
if (!function_exists('rcopy')) { | ||
function rcopy($src, $dest) | ||
{ | ||
|
||
// If source is not a directory stop processing | ||
if (!is_dir($src)) { | ||
return false; | ||
} | ||
|
||
// If the destination directory does not exist create it | ||
if (!is_dir($dest)) { | ||
if (!mkdir($dest)) { | ||
// If the destination directory could not be created stop processing | ||
return false; | ||
} | ||
} | ||
|
||
// Open the source directory to read in files | ||
$i = new DirectoryIterator($src); | ||
foreach ($i as $f) { | ||
if ($f->isFile()) { | ||
copy($f->getRealPath(), "$dest/" . $f->getFilename()); | ||
} elseif (!$f->isDot() && $f->isDir()) { | ||
rcopy($f->getRealPath(), "$dest/$f"); | ||
} | ||
} | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
...t/ApiDoc/Generators/AbstractGenerator.php → ...r/ApiDoc/Generators/AbstractGenerator.php
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
2 changes: 1 addition & 1 deletion
2
...ciot/ApiDoc/Generators/DingoGenerator.php → ...oder/ApiDoc/Generators/DingoGenerator.php
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Mpociot\ApiDoc\Generators; | ||
namespace Oxycoder\ApiDoc\Generators; | ||
|
||
use Exception; | ||
|
||
|
4 changes: 2 additions & 2 deletions
4
...ot/ApiDoc/Generators/LaravelGenerator.php → ...er/ApiDoc/Generators/LaravelGenerator.php
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
2 changes: 1 addition & 1 deletion
2
.../ApiDoc/Parsers/RuleDescriptionParser.php → .../ApiDoc/Parsers/RuleDescriptionParser.php
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Mpociot\ApiDoc\Parsers; | ||
namespace Oxycoder\ApiDoc\Parsers; | ||
|
||
class RuleDescriptionParser | ||
{ | ||
|
2 changes: 1 addition & 1 deletion
2
...ociot/ApiDoc/Postman/CollectionWriter.php → ...coder/ApiDoc/Postman/CollectionWriter.php
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
Oops, something went wrong.