@@ -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,18 +74,18 @@ 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', $this->shouldGeneratePostmanCollection()); |
85 | 85 | |
86 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) { |
|
87 | - return $routeGroup->map(function ($route) { |
|
88 | - if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) { |
|
86 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) { |
|
87 | + return $routeGroup->map(function($route) { |
|
88 | + if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) { |
|
89 | 89 | $route['headers']['Content-Type'] = 'application/json'; |
90 | 90 | } |
91 | 91 | $route['output'] = (string) view('apidoc::partials.route')->with('route', $route)->render(); |
@@ -107,16 +107,16 @@ discard block |
||
107 | 107 | $frontmatter = trim($generatedFrontmatter[1], "\n"); |
108 | 108 | } |
109 | 109 | |
110 | - $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
111 | - return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
112 | - if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
113 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
110 | + $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
111 | + return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
112 | + if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
113 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
114 | 114 | if ($routeDocumentationChanged === false || $this->option('force')) { |
115 | 115 | if ($routeDocumentationChanged) { |
116 | - $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
116 | + $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
117 | 117 | } |
118 | 118 | } else { |
119 | - $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
119 | + $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
120 | 120 | $route['modified_output'] = $existingRouteDoc[0]; |
121 | 121 | } |
122 | 122 | } |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | } |
128 | 128 | |
129 | 129 | $prependFileContents = file_exists($prependFile) |
130 | - ? file_get_contents($prependFile)."\n" : ''; |
|
130 | + ? file_get_contents($prependFile) . "\n" : ''; |
|
131 | 131 | $appendFileContents = file_exists($appendFile) |
132 | - ? "\n".file_get_contents($appendFile) : ''; |
|
132 | + ? "\n" . file_get_contents($appendFile) : ''; |
|
133 | 133 | |
134 | 134 | $documentarian = new Documentarian(); |
135 | 135 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection()) |
144 | 144 | ->with('parsedRoutes', $parsedRouteOutput); |
145 | 145 | |
146 | - if (! is_dir($outputPath)) { |
|
146 | + if (!is_dir($outputPath)) { |
|
147 | 147 | $documentarian->create($outputPath); |
148 | 148 | } |
149 | 149 | |
@@ -163,24 +163,24 @@ discard block |
||
163 | 163 | |
164 | 164 | file_put_contents($compareFile, $compareMarkdown); |
165 | 165 | |
166 | - $this->info('Wrote index.md to: '.$outputPath); |
|
166 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
167 | 167 | |
168 | 168 | $this->info('Generating API HTML code'); |
169 | 169 | |
170 | 170 | $documentarian->generate($outputPath); |
171 | 171 | |
172 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
172 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
173 | 173 | |
174 | 174 | if ($this->shouldGeneratePostmanCollection()) { |
175 | 175 | $this->info('Generating Postman collection'); |
176 | 176 | |
177 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
177 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | if ($logo = config('apidoc.logo')) { |
181 | 181 | copy( |
182 | 182 | $logo, |
183 | - $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png' |
|
183 | + $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png' |
|
184 | 184 | ); |
185 | 185 | } |
186 | 186 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | /** @var Route $route */ |
200 | 200 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
201 | 201 | $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']); |
202 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
202 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
203 | 203 | } else { |
204 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
204 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | private function isValidRoute(Route $route) |
217 | 217 | { |
218 | - return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
218 | + return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | list($class, $method) = explode('@', $route); |
231 | 231 | $reflection = new ReflectionClass($class); |
232 | 232 | |
233 | - if (! $reflection->hasMethod($method)) { |
|
233 | + if (!$reflection->hasMethod($method)) { |
|
234 | 234 | return false; |
235 | 235 | } |
236 | 236 | |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | $phpdoc = new DocBlock($comment); |
241 | 241 | |
242 | 242 | return collect($phpdoc->getTags()) |
243 | - ->filter(function ($tag) use ($route) { |
|
243 | + ->filter(function($tag) use ($route) { |
|
244 | 244 | return $tag->getName() === 'hideFromAPIDocumentation'; |
245 | 245 | }) |
246 | 246 | ->isEmpty(); |