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