@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | /** |
| 15 | 15 | * @param Route $route |
| 16 | 16 | * |
| 17 | - * @return mixed |
|
| 17 | + * @return string |
|
| 18 | 18 | */ |
| 19 | 19 | public function getUri(Route $route) |
| 20 | 20 | { |
@@ -33,7 +33,6 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * @param \Illuminate\Routing\Route $route |
| 36 | - * @param array $apply Rules to apply when generating documentation for this route |
|
| 37 | 36 | * |
| 38 | 37 | * @return array |
| 39 | 38 | */ |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $generator = new Generator(config('apidoc.faker_seed')); |
| 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,19 +74,19 @@ 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 | 86 | $settings = ['languages' => config('apidoc.example_languages')]; |
| 87 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) use ($settings) { |
|
| 88 | - return $routeGroup->map(function ($route) use ($settings) { |
|
| 89 | - if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) { |
|
| 87 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) use ($settings) { |
|
| 88 | + return $routeGroup->map(function($route) use ($settings) { |
|
| 89 | + if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) { |
|
| 90 | 90 | $route['headers']['Content-Type'] = 'application/json'; |
| 91 | 91 | } |
| 92 | 92 | $route['output'] = (string) view('apidoc::partials.route') |
@@ -112,16 +112,16 @@ discard block |
||
| 112 | 112 | $frontmatter = trim($generatedFrontmatter[1], "\n"); |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
| 116 | - return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
| 117 | - if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
| 118 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
| 115 | + $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
| 116 | + return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
| 117 | + if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
| 118 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
| 119 | 119 | if ($routeDocumentationChanged === false || $this->option('force')) { |
| 120 | 120 | if ($routeDocumentationChanged) { |
| 121 | - $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
| 121 | + $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
| 122 | 122 | } |
| 123 | 123 | } else { |
| 124 | - $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
| 124 | + $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
| 125 | 125 | $route['modified_output'] = $existingRouteDoc[0]; |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $prependFileContents = file_exists($prependFile) |
| 135 | - ? file_get_contents($prependFile)."\n" : ''; |
|
| 135 | + ? file_get_contents($prependFile) . "\n" : ''; |
|
| 136 | 136 | $appendFileContents = file_exists($appendFile) |
| 137 | - ? "\n".file_get_contents($appendFile) : ''; |
|
| 137 | + ? "\n" . file_get_contents($appendFile) : ''; |
|
| 138 | 138 | |
| 139 | 139 | $documentarian = new Documentarian(); |
| 140 | 140 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | ->with('showPostmanCollectionButton', $this->shouldGeneratePostmanCollection()) |
| 149 | 149 | ->with('parsedRoutes', $parsedRouteOutput); |
| 150 | 150 | |
| 151 | - if (! is_dir($outputPath)) { |
|
| 151 | + if (!is_dir($outputPath)) { |
|
| 152 | 152 | $documentarian->create($outputPath); |
| 153 | 153 | } |
| 154 | 154 | |
@@ -168,24 +168,24 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | file_put_contents($compareFile, $compareMarkdown); |
| 170 | 170 | |
| 171 | - $this->info('Wrote index.md to: '.$outputPath); |
|
| 171 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
| 172 | 172 | |
| 173 | 173 | $this->info('Generating API HTML code'); |
| 174 | 174 | |
| 175 | 175 | $documentarian->generate($outputPath); |
| 176 | 176 | |
| 177 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
| 177 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
| 178 | 178 | |
| 179 | 179 | if ($this->shouldGeneratePostmanCollection()) { |
| 180 | 180 | $this->info('Generating Postman collection'); |
| 181 | 181 | |
| 182 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
| 182 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | if ($logo = config('apidoc.logo')) { |
| 186 | 186 | copy( |
| 187 | 187 | $logo, |
| 188 | - $outputPath.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'logo.png' |
|
| 188 | + $outputPath . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'logo.png' |
|
| 189 | 189 | ); |
| 190 | 190 | } |
| 191 | 191 | } |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | /** @var Route $route */ |
| 205 | 205 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
| 206 | 206 | $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']); |
| 207 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
| 207 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
| 208 | 208 | } else { |
| 209 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
| 209 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
| 210 | 210 | } |
| 211 | 211 | } |
| 212 | 212 | |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | private function isValidRoute(Route $route) |
| 222 | 222 | { |
| 223 | - return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
| 223 | + return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /** |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | list($class, $method) = explode('@', $route); |
| 236 | 236 | $reflection = new ReflectionClass($class); |
| 237 | 237 | |
| 238 | - if (! $reflection->hasMethod($method)) { |
|
| 238 | + if (!$reflection->hasMethod($method)) { |
|
| 239 | 239 | return false; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | $phpdoc = new DocBlock($comment); |
| 246 | 246 | |
| 247 | 247 | return collect($phpdoc->getTags()) |
| 248 | - ->filter(function ($tag) use ($route) { |
|
| 248 | + ->filter(function($tag) use ($route) { |
|
| 249 | 249 | return $tag->getName() === 'hideFromAPIDocumentation'; |
| 250 | 250 | }) |
| 251 | 251 | ->isEmpty(); |