@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | $generator = new Generator(); |
56 | 56 | $parsedRoutes = $this->processRoutes($generator, $routes); |
57 | 57 | $parsedRoutes = collect($parsedRoutes)->groupBy('group') |
58 | - ->sortBy(static function ($group) { |
|
58 | + ->sortBy(static function($group) { |
|
59 | 59 | /** @var $group Collection */ |
60 | 60 | return $group->first()['group']; |
61 | 61 | }, SORT_NATURAL); |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | private function writeMarkdown($parsedRoutes) |
72 | 72 | { |
73 | 73 | $outputPath = config('apidoc.output'); |
74 | - $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
75 | - $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
76 | - $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md'; |
|
77 | - $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md'; |
|
74 | + $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
75 | + $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
76 | + $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md'; |
|
77 | + $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md'; |
|
78 | 78 | |
79 | 79 | $infoText = view('apidoc::partials.info') |
80 | 80 | ->with('outputPath', ltrim($outputPath, 'public/')) |
81 | 81 | ->with('showPostmanCollectionButton', config('apidoc.postman')); |
82 | 82 | |
83 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) { |
|
84 | - return $routeGroup->map(function ($route) { |
|
83 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) { |
|
84 | + return $routeGroup->map(function($route) { |
|
85 | 85 | $route['output'] = (string) view('apidoc::partials.route')->with('route', $route)->render(); |
86 | 86 | |
87 | 87 | return $route; |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | $frontmatter = trim($generatedFrontmatter[1], "\n"); |
102 | 102 | } |
103 | 103 | |
104 | - $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
105 | - return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
106 | - if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
107 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
104 | + $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
105 | + return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
106 | + if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
107 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
108 | 108 | if ($routeDocumentationChanged === false || $this->option('force')) { |
109 | 109 | if ($routeDocumentationChanged) { |
110 | - $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
110 | + $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
111 | 111 | } |
112 | 112 | } else { |
113 | - $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
113 | + $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
114 | 114 | $route['modified_output'] = $existingRouteDoc[0]; |
115 | 115 | } |
116 | 116 | } |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | } |
122 | 122 | |
123 | 123 | $prependFileContents = file_exists($prependFile) |
124 | - ? file_get_contents($prependFile)."\n" : ''; |
|
124 | + ? file_get_contents($prependFile) . "\n" : ''; |
|
125 | 125 | $appendFileContents = file_exists($appendFile) |
126 | - ? "\n".file_get_contents($appendFile) : ''; |
|
126 | + ? "\n" . file_get_contents($appendFile) : ''; |
|
127 | 127 | |
128 | 128 | $documentarian = new Documentarian(); |
129 | 129 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | ->with('showPostmanCollectionButton', config('apidoc.postman')) |
138 | 138 | ->with('parsedRoutes', $parsedRouteOutput); |
139 | 139 | |
140 | - if (! is_dir($outputPath)) { |
|
140 | + if (!is_dir($outputPath)) { |
|
141 | 141 | $documentarian->create($outputPath); |
142 | 142 | } |
143 | 143 | |
@@ -157,24 +157,24 @@ discard block |
||
157 | 157 | |
158 | 158 | file_put_contents($compareFile, $compareMarkdown); |
159 | 159 | |
160 | - $this->info('Wrote index.md to: '.$outputPath); |
|
160 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
161 | 161 | |
162 | 162 | $this->info('Generating API HTML code'); |
163 | 163 | |
164 | 164 | $documentarian->generate($outputPath); |
165 | 165 | |
166 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
166 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
167 | 167 | |
168 | 168 | if (config('apidoc.postman')) { |
169 | 169 | $this->info('Generating Postman collection'); |
170 | 170 | |
171 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
171 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | if ($logo = config('apidoc.logo')) { |
175 | 175 | copy( |
176 | 176 | $logo, |
177 | - $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png' |
|
177 | + $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png' |
|
178 | 178 | ); |
179 | 179 | } |
180 | 180 | } |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | /** @var Route $route */ |
194 | 194 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
195 | 195 | $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']); |
196 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
196 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
197 | 197 | } else { |
198 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
198 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | private function isValidRoute(Route $route) |
211 | 211 | { |
212 | - return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
212 | + return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $phpdoc = new DocBlock($comment); |
227 | 227 | |
228 | 228 | return collect($phpdoc->getTags()) |
229 | - ->filter(function ($tag) use ($route) { |
|
229 | + ->filter(function($tag) use ($route) { |
|
230 | 230 | return $tag->getName() === 'hideFromAPIDocumentation'; |
231 | 231 | }) |
232 | 232 | ->isEmpty(); |