@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $generator = new Generator(); |
59 | 59 | $parsedRoutes = $this->processRoutes($generator, $routes); |
60 | 60 | $parsedRoutes = collect($parsedRoutes)->groupBy('group') |
61 | - ->sortBy(static function ($group) { |
|
61 | + ->sortBy(static function($group) { |
|
62 | 62 | /* @var $group Collection */ |
63 | 63 | return $group->first()['group']; |
64 | 64 | }, SORT_NATURAL); |
@@ -74,17 +74,17 @@ discard block |
||
74 | 74 | private function writeMarkdown($parsedRoutes) |
75 | 75 | { |
76 | 76 | $outputPath = config('apidoc.output'); |
77 | - $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
78 | - $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
79 | - $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md'; |
|
80 | - $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md'; |
|
77 | + $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
78 | + $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
79 | + $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md'; |
|
80 | + $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md'; |
|
81 | 81 | |
82 | 82 | $infoText = view('apidoc::partials.info') |
83 | 83 | ->with('outputPath', ltrim($outputPath, 'public/')) |
84 | 84 | ->with('showPostmanCollectionButton', config('apidoc.postman')); |
85 | 85 | |
86 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) { |
|
87 | - return $routeGroup->map(function ($route) { |
|
86 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) { |
|
87 | + return $routeGroup->map(function($route) { |
|
88 | 88 | $route['output'] = (string) view('apidoc::partials.route')->with('route', $route)->render(); |
89 | 89 | |
90 | 90 | return $route; |
@@ -104,16 +104,16 @@ discard block |
||
104 | 104 | $frontmatter = trim($generatedFrontmatter[1], "\n"); |
105 | 105 | } |
106 | 106 | |
107 | - $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
108 | - return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
109 | - if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
110 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
107 | + $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
108 | + return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
109 | + if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
110 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
111 | 111 | if ($routeDocumentationChanged === false || $this->option('force')) { |
112 | 112 | if ($routeDocumentationChanged) { |
113 | - $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
113 | + $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
114 | 114 | } |
115 | 115 | } else { |
116 | - $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
116 | + $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
117 | 117 | $route['modified_output'] = $existingRouteDoc[0]; |
118 | 118 | } |
119 | 119 | } |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | } |
125 | 125 | |
126 | 126 | $prependFileContents = file_exists($prependFile) |
127 | - ? file_get_contents($prependFile)."\n" : ''; |
|
127 | + ? file_get_contents($prependFile) . "\n" : ''; |
|
128 | 128 | $appendFileContents = file_exists($appendFile) |
129 | - ? "\n".file_get_contents($appendFile) : ''; |
|
129 | + ? "\n" . file_get_contents($appendFile) : ''; |
|
130 | 130 | |
131 | 131 | $documentarian = new Documentarian(); |
132 | 132 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | ->with('showPostmanCollectionButton', config('apidoc.postman')) |
141 | 141 | ->with('parsedRoutes', $parsedRouteOutput); |
142 | 142 | |
143 | - if (! is_dir($outputPath)) { |
|
143 | + if (!is_dir($outputPath)) { |
|
144 | 144 | $documentarian->create($outputPath); |
145 | 145 | } |
146 | 146 | |
@@ -160,24 +160,24 @@ discard block |
||
160 | 160 | |
161 | 161 | file_put_contents($compareFile, $compareMarkdown); |
162 | 162 | |
163 | - $this->info('Wrote index.md to: '.$outputPath); |
|
163 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
164 | 164 | |
165 | 165 | $this->info('Generating API HTML code'); |
166 | 166 | |
167 | 167 | $documentarian->generate($outputPath); |
168 | 168 | |
169 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
169 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
170 | 170 | |
171 | 171 | if (config('apidoc.postman')) { |
172 | 172 | $this->info('Generating Postman collection'); |
173 | 173 | |
174 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
174 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | if ($logo = config('apidoc.logo')) { |
178 | 178 | copy( |
179 | 179 | $logo, |
180 | - $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png' |
|
180 | + $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png' |
|
181 | 181 | ); |
182 | 182 | } |
183 | 183 | } |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | /** @var Route $route */ |
197 | 197 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
198 | 198 | $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']); |
199 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
199 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
200 | 200 | } else { |
201 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
201 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | */ |
213 | 213 | private function isValidRoute(Route $route) |
214 | 214 | { |
215 | - return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
215 | + return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | list($class, $method) = explode('@', $route); |
228 | 228 | $reflection = new ReflectionClass($class); |
229 | 229 | |
230 | - if (! $reflection->hasMethod($method)) { |
|
230 | + if (!$reflection->hasMethod($method)) { |
|
231 | 231 | return false; |
232 | 232 | } |
233 | 233 | |
@@ -242,17 +242,17 @@ discard block |
||
242 | 242 | if ($comment) { |
243 | 243 | $phpdoc = new DocBlock($comment); |
244 | 244 | |
245 | - if (count($allowedTags) && ! $phpdoc->hasTag('tags')) { |
|
245 | + if (count($allowedTags) && !$phpdoc->hasTag('tags')) { |
|
246 | 246 | return false; |
247 | 247 | } |
248 | 248 | return collect($phpdoc->getTags()) |
249 | - ->filter(function ($tag) use ($route, $allowedTags, $disallowedTags) { |
|
249 | + ->filter(function($tag) use ($route, $allowedTags, $disallowedTags) { |
|
250 | 250 | if ((count($allowedTags) || count($disallowedTags)) && |
251 | 251 | $tag->getName() == 'tags') { |
252 | 252 | $tags = explode(' ', $tag->getContent()); |
253 | 253 | $containedAllowedTags = array_intersect($tags, $allowedTags); |
254 | 254 | $containedDisallowedTags = array_intersect($tags, $disallowedTags); |
255 | - return ! count($containedAllowedTags) || count($containedDisallowedTags); |
|
255 | + return !count($containedAllowedTags) || count($containedDisallowedTags); |
|
256 | 256 | } |
257 | 257 | return $tag->getName() === 'hideFromAPIDocumentation'; |
258 | 258 | }) |