Skip to content

Commit 95e3f4b

Browse files
committed
update name space, struct
1 parent e7239fc commit 95e3f4b

File tree

79 files changed

+9310
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+9310
-59
lines changed

composer.json

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
{
2-
"name": "mpociot/laravel-apidoc-generator",
2+
"name": "oxycoder/laravel-apidoc-generator",
33
"license": "MIT",
44
"description": "Generate beautiful API documentation from your Laravel application",
55
"keywords": [
66
"API",
77
"Documentation",
88
"Laravel"
99
],
10-
"homepage": "http://github.com/mpociot/laravel-apidoc-generator",
10+
"homepage": "http://github.com/oxycoder/laravel-apidoc-generator",
1111
"authors": [
1212
{
13-
"name": "Marcel Pociot",
13+
"name": "Tung",
1414
"email": "[email protected]"
1515
}
1616
],
1717
"require": {
1818
"php": ">=5.5.0",
1919
"fzaninotto/faker": "~1.0",
2020
"laravel/framework": "~5.4",
21-
"mpociot/documentarian": "^0.2.0",
22-
"mpociot/reflection-docblock": "^1.0",
23-
"ramsey/uuid": "^3.0"
21+
"ramsey/uuid": "^3.0",
22+
"mnapoli/front-yaml": "^1.5",
23+
"windwalker/renderer": "3.*",
24+
"mnapoli/silly": "~1.0",
25+
"illuminate/view": "5.*"
2426
},
2527
"require-dev": {
2628
"orchestra/testbench": "~3.0",
@@ -29,19 +31,22 @@
2931
"mockery/mockery": "^0.9.5"
3032
},
3133
"autoload": {
34+
"files": [
35+
"src/Oxycoder/ApiDoc/Documentarian/helpers.php"
36+
],
3237
"psr-0": {
33-
"Mpociot\\ApiDoc": "src/"
38+
"Oxycoder\\ApiDoc": "src/"
3439
}
3540
},
3641
"autoload-dev": {
3742
"psr-4": {
38-
"Mpociot\\ApiDoc\\Tests\\": "tests/"
43+
"Oxycoder\\ApiDoc\\Tests\\": "tests/"
3944
}
4045
},
4146
"extra": {
4247
"laravel": {
4348
"providers": [
44-
"Mpociot\\ApiDoc\\ApiDocGeneratorServiceProvider"
49+
"Oxycoder\\ApiDoc\\ApiDocGeneratorServiceProvider"
4550
]
4651
}
4752
}

src/Mpociot/ApiDoc/ApiDocGeneratorServiceProvider.php renamed to src/Oxycoder/ApiDoc/ApiDocGeneratorServiceProvider.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?php
22

3-
namespace Mpociot\ApiDoc;
3+
namespace Oxycoder\ApiDoc;
44

55
use Illuminate\Support\ServiceProvider;
6-
use Mpociot\ApiDoc\Commands\UpdateDocumentation;
7-
use Mpociot\ApiDoc\Commands\GenerateDocumentation;
6+
use Oxycoder\ApiDoc\Commands\UpdateDocumentation;
7+
use Oxycoder\ApiDoc\Commands\GenerateDocumentation;
88

99
class ApiDocGeneratorServiceProvider extends ServiceProvider
1010
{
@@ -21,6 +21,7 @@ public function boot()
2121
$this->publishes([
2222
__DIR__.'/../../resources/lang' => $this->resource_path('lang/vendor/apidoc'),
2323
__DIR__.'/../../resources/views' => $this->resource_path('views/vendor/apidoc'),
24+
__DIR__.'/../../resources/assets' => $this->resource_path('views/vendor/assets'),
2425
]);
2526
}
2627

src/Mpociot/ApiDoc/Commands/GenerateDocumentation.php renamed to src/Oxycoder/ApiDoc/Commands/GenerateDocumentation.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
22

3-
namespace Mpociot\ApiDoc\Commands;
3+
namespace Oxycoder\ApiDoc\Commands;
44

55
use ReflectionClass;
66
use Illuminate\Console\Command;
7-
use Mpociot\Reflection\DocBlock;
7+
use Oxycoder\Reflection\DocBlock;
88
use Illuminate\Support\Collection;
99
use Illuminate\Support\Facades\Route;
10-
use Mpociot\Documentarian\Documentarian;
11-
use Mpociot\ApiDoc\Postman\CollectionWriter;
12-
use Mpociot\ApiDoc\Generators\DingoGenerator;
13-
use Mpociot\ApiDoc\Generators\LaravelGenerator;
14-
use Mpociot\ApiDoc\Generators\AbstractGenerator;
10+
use Oxycoder\Documentarian\Documentarian;
11+
use Oxycoder\ApiDoc\Postman\CollectionWriter;
12+
use Oxycoder\ApiDoc\Generators\DingoGenerator;
13+
use Oxycoder\ApiDoc\Generators\LaravelGenerator;
14+
use Oxycoder\ApiDoc\Generators\AbstractGenerator;
1515

1616
class GenerateDocumentation extends Command
1717
{

src/Mpociot/ApiDoc/Commands/UpdateDocumentation.php renamed to src/Oxycoder/ApiDoc/Commands/UpdateDocumentation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22

3-
namespace Mpociot\ApiDoc\Commands;
3+
namespace Oxycoder\ApiDoc\Commands;
44

55
use Illuminate\Console\Command;
6-
use Mpociot\Documentarian\Documentarian;
6+
use Oxycoder\Documentarian\Documentarian;
77

88
class UpdateDocumentation extends Command
99
{
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
3+
namespace Oxycoder\Documentarian;
4+
5+
use Mni\FrontYAML\Parser;
6+
use Windwalker\Renderer\BladeRenderer;
7+
8+
/**
9+
* Class Documentarian
10+
* @package Mpociot\Documentarian
11+
*/
12+
class Documentarian
13+
{
14+
15+
/**
16+
* Returns a config value
17+
*
18+
* @param string $key
19+
* @return mixed
20+
*/
21+
public function config($folder, $key = null)
22+
{
23+
$config = include($folder . '/source/config.php');
24+
25+
return is_null($key) ? $config : array_get($config, $key);
26+
}
27+
28+
/**
29+
* Create a new API documentation folder and copy all needed files/stubs
30+
*
31+
* @param $folder
32+
*/
33+
public function create($folder)
34+
{
35+
$folder = $folder . '/source';
36+
if (!is_dir($folder)) {
37+
mkdir($folder, 0777, true);
38+
mkdir($folder . '/../css');
39+
mkdir($folder . '/../js');
40+
mkdir($folder . '/includes');
41+
mkdir($folder . '/assets');
42+
}
43+
44+
// copy stub files
45+
copy(__DIR__ . '/../../resources/assets/stubs/index.md', $folder . '/index.md');
46+
copy(__DIR__ . '/../../resources/assets/stubs/gitignore.stub', $folder . '/.gitignore');
47+
copy(__DIR__ . '/../../resources/assets/stubs/includes/_errors.md', $folder . '/includes/_errors.md');
48+
copy(__DIR__ . '/../../resources/assets/stubs/package.json', $folder . '/package.json');
49+
copy(__DIR__ . '/../../resources/assets/stubs/gulpfile.js', $folder . '/gulpfile.js');
50+
copy(__DIR__ . '/../../resources/assets/stubs/config.php', $folder . '/config.php');
51+
copy(__DIR__ . '/../../resources/assets/stubs/js/all.js', $folder . '/../js/all.js');
52+
copy(__DIR__ . '/../../resources/assets/stubs/css/style.css', $folder . '/../css/style.css');
53+
54+
// copy resources
55+
rcopy(__DIR__ . '/../../resources/assets/images/', $folder . '/assets/images');
56+
rcopy(__DIR__ . '/../../resources/assets/js/', $folder . '/assets/js');
57+
rcopy(__DIR__ . '/../../resources/assets/stylus/', $folder . '/assets/stylus');
58+
}
59+
60+
/**
61+
* Generate the API documentation using the markdown and include files
62+
*
63+
* @param $folder
64+
* @return false|null
65+
*/
66+
public function generate($folder)
67+
{
68+
$source_dir = $folder . '/source';
69+
70+
if (!is_dir($source_dir)) {
71+
return false;
72+
}
73+
74+
$parser = new Parser();
75+
76+
$document = $parser->parse(file_get_contents($source_dir . '/index.md'));
77+
78+
$frontmatter = $document->getYAML();
79+
$html = $document->getContent();
80+
81+
$renderer = new BladeRenderer([__DIR__ . '/../../resources/views'], ['cache_path' => $source_dir . '/_tmp']);
82+
83+
// Parse and include optional include markdown files
84+
if (isset($frontmatter['includes'])) {
85+
foreach ($frontmatter['includes'] as $include) {
86+
if (file_exists($include_file = $source_dir . '/includes/_' . $include . '.md')) {
87+
$document = $parser->parse(file_get_contents($include_file));
88+
$html .= $document->getContent();
89+
}
90+
}
91+
}
92+
93+
$output = $renderer->render('index', [
94+
'page' => $frontmatter,
95+
'content' => $html
96+
]);
97+
98+
file_put_contents($folder . '/index.html', $output);
99+
100+
// Copy assets
101+
rcopy($source_dir . '/assets/images/', $folder . '/images');
102+
rcopy($source_dir . '/assets/stylus/fonts/', $folder . '/css/fonts');
103+
}
104+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Output the given text to the console.
4+
*
5+
* @param string $output
6+
* @return void
7+
*/
8+
if (!function_exists('info')) {
9+
function info($output)
10+
{
11+
output('<info>' . $output . '</info>');
12+
}
13+
}
14+
15+
/**
16+
* Output the given text to the console.
17+
*
18+
* @param string $output
19+
* @return void
20+
*/
21+
if (!function_exists('output')) {
22+
function output($output)
23+
{
24+
if (isset($_ENV['APP_ENV']) && $_ENV['APP_ENV'] == 'testing') {
25+
return;
26+
}
27+
(new Symfony\Component\Console\Output\ConsoleOutput)->writeln($output);
28+
}
29+
}
30+
31+
/**
32+
* Recursively copy files from one directory to another
33+
*
34+
* @param String $src - Source of files being moved
35+
* @param String $dest - Destination of files being moved
36+
* @return bool
37+
*/
38+
39+
if (!function_exists('rcopy')) {
40+
function rcopy($src, $dest)
41+
{
42+
43+
// If source is not a directory stop processing
44+
if (!is_dir($src)) {
45+
return false;
46+
}
47+
48+
// If the destination directory does not exist create it
49+
if (!is_dir($dest)) {
50+
if (!mkdir($dest)) {
51+
// If the destination directory could not be created stop processing
52+
return false;
53+
}
54+
}
55+
56+
// Open the source directory to read in files
57+
$i = new DirectoryIterator($src);
58+
foreach ($i as $f) {
59+
if ($f->isFile()) {
60+
copy($f->getRealPath(), "$dest/" . $f->getFilename());
61+
} elseif (!$f->isDot() && $f->isDir()) {
62+
rcopy($f->getRealPath(), "$dest/$f");
63+
}
64+
}
65+
}
66+
}

src/Mpociot/ApiDoc/Generators/AbstractGenerator.php renamed to src/Oxycoder/ApiDoc/Generators/AbstractGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
22

3-
namespace Mpociot\ApiDoc\Generators;
3+
namespace Oxycoder\ApiDoc\Generators;
44

55
use Faker\Factory;
66
use ReflectionClass;
77
use Illuminate\Support\Arr;
88
use Illuminate\Support\Str;
9-
use Mpociot\Reflection\DocBlock;
10-
use Mpociot\Reflection\DocBlock\Tag;
9+
use Oxycoder\Reflection\DocBlock;
10+
use Oxycoder\Reflection\DocBlock\Tag;
1111
use Illuminate\Support\Facades\Validator;
1212
use Illuminate\Foundation\Http\FormRequest;
13-
use Mpociot\ApiDoc\Parsers\RuleDescriptionParser as Description;
13+
use Oxycoder\ApiDoc\Parsers\RuleDescriptionParser as Description;
1414

1515
abstract class AbstractGenerator
1616
{

src/Mpociot/ApiDoc/Generators/DingoGenerator.php renamed to src/Oxycoder/ApiDoc/Generators/DingoGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Mpociot\ApiDoc\Generators;
3+
namespace Oxycoder\ApiDoc\Generators;
44

55
use Exception;
66

src/Mpociot/ApiDoc/Generators/LaravelGenerator.php renamed to src/Oxycoder/ApiDoc/Generators/LaravelGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Mpociot\ApiDoc\Generators;
3+
namespace Oxycoder\ApiDoc\Generators;
44

55
use ReflectionClass;
66
use League\Fractal\Manager;
77
use Illuminate\Routing\Route;
88
use League\Fractal\Resource\Item;
99
use Illuminate\Support\Facades\App;
10-
use Mpociot\Reflection\DocBlock\Tag;
10+
use Oxycoder\Reflection\DocBlock\Tag;
1111
use Illuminate\Support\Facades\Request;
1212
use League\Fractal\Resource\Collection;
1313
use Illuminate\Foundation\Http\FormRequest;

src/Mpociot/ApiDoc/Parsers/RuleDescriptionParser.php renamed to src/Oxycoder/ApiDoc/Parsers/RuleDescriptionParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Mpociot\ApiDoc\Parsers;
3+
namespace Oxycoder\ApiDoc\Parsers;
44

55
class RuleDescriptionParser
66
{

0 commit comments

Comments
 (0)