|
@@ -70,7 +70,7 @@ discard block |
|
|
block discarded – undo |
|
70
|
70
|
|
|
71
|
71
|
$this->setUserToBeImpersonated($this->option('actAsUserId')); |
|
72
|
72
|
|
|
73
|
|
- if ($routePrefix === null && ! count($allowedRoutes) && $middleware === null) { |
|
|
73
|
+ if ($routePrefix === null && !count($allowedRoutes) && $middleware === null) { |
|
74
|
74
|
$this->error('You must provide either a route prefix or a route or a middleware to generate the documentation.'); |
|
75
|
75
|
|
|
76
|
76
|
return false; |
|
@@ -94,15 +94,15 @@ discard block |
|
|
block discarded – undo |
|
94
|
94
|
private function writeMarkdown($parsedRoutes) |
|
95
|
95
|
{ |
|
96
|
96
|
$outputPath = $this->option('output'); |
|
97
|
|
- $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
98
|
|
- $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
|
97
|
+ $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
|
98
|
+ $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
99
|
99
|
|
|
100
|
100
|
$infoText = view('apidoc::partials.info') |
|
101
|
101
|
->with('outputPath', ltrim($outputPath, 'public/')) |
|
102
|
|
- ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')); |
|
|
102
|
+ ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')); |
|
103
|
103
|
|
|
104
|
|
- $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) { |
|
105
|
|
- return $routeGroup->map(function ($route) { |
|
|
104
|
+ $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) { |
|
|
105
|
+ return $routeGroup->map(function($route) { |
|
106
|
106
|
$route['output'] = (string) view('apidoc::partials.route')->with('parsedRoute', $route); |
|
107
|
107
|
|
|
108
|
108
|
return $route; |
|
@@ -126,16 +126,16 @@ discard block |
|
|
block discarded – undo |
|
126
|
126
|
$frontmatter = trim($generatedFrontmatter[1], "\n"); |
|
127
|
127
|
} |
|
128
|
128
|
|
|
129
|
|
- $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
130
|
|
- return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
131
|
|
- if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $routeMatch)) { |
|
132
|
|
- $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
133
|
|
- if ($routeDocumentationChanged === false || $this->option('force')) { |
|
|
129
|
+ $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
|
130
|
+ return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
|
131
|
+ if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $routeMatch)) { |
|
|
132
|
+ $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
|
133
|
+ if ($routeDocumentationChanged === false || $this->option('force')) { |
|
134
|
134
|
if ($routeDocumentationChanged) { |
|
135
|
|
- $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
|
135
|
+ $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
136
|
136
|
} |
|
137
|
137
|
} else { |
|
138
|
|
- $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
|
138
|
+ $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
139
|
139
|
$route['modified_output'] = $routeMatch[0]; |
|
140
|
140
|
} |
|
141
|
141
|
} |
|
@@ -152,10 +152,10 @@ discard block |
|
|
block discarded – undo |
|
152
|
152
|
->with('frontmatter', $frontmatter) |
|
153
|
153
|
->with('infoText', $infoText) |
|
154
|
154
|
->with('outputPath', $this->option('output')) |
|
155
|
|
- ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
|
155
|
+ ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
156
|
156
|
->with('parsedRoutes', $parsedRouteOutput); |
|
157
|
157
|
|
|
158
|
|
- if (! is_dir($outputPath)) { |
|
|
158
|
+ if (!is_dir($outputPath)) { |
|
159
|
159
|
$documentarian->create($outputPath); |
|
160
|
160
|
} |
|
161
|
161
|
|
|
@@ -168,24 +168,24 @@ discard block |
|
|
block discarded – undo |
|
168
|
168
|
->with('frontmatter', $frontmatter) |
|
169
|
169
|
->with('infoText', $infoText) |
|
170
|
170
|
->with('outputPath', $this->option('output')) |
|
171
|
|
- ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
|
171
|
+ ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
172
|
172
|
->with('parsedRoutes', $parsedRouteOutput); |
|
173
|
173
|
|
|
174
|
174
|
file_put_contents($compareFile, $compareMarkdown); |
|
175
|
175
|
|
|
176
|
|
- $this->info('Wrote index.md to: '.$outputPath); |
|
|
176
|
+ $this->info('Wrote index.md to: ' . $outputPath); |
|
177
|
177
|
|
|
178
|
178
|
$this->info('Generating API HTML code'); |
|
179
|
179
|
|
|
180
|
180
|
$documentarian->generate($outputPath); |
|
181
|
181
|
|
|
182
|
|
- $this->info('Wrote HTML documentation to: '.$outputPath.'/public/index.html'); |
|
|
182
|
+ $this->info('Wrote HTML documentation to: ' . $outputPath . '/public/index.html'); |
|
183
|
183
|
|
|
184
|
184
|
|
|
185
|
185
|
if ($this->option('noPostmanCollection') !== true) { |
|
186
|
186
|
$this->info('Generating Postman collection'); |
|
187
|
187
|
|
|
188
|
|
- file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
|
188
|
+ file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
189
|
189
|
} |
|
190
|
190
|
} |
|
191
|
191
|
|
|
@@ -213,7 +213,7 @@ discard block |
|
|
block discarded – undo |
|
213
|
213
|
*/ |
|
214
|
214
|
private function setUserToBeImpersonated($actAs) |
|
215
|
215
|
{ |
|
216
|
|
- if (! empty($actAs)) { |
|
|
216
|
+ if (!empty($actAs)) { |
|
217
|
217
|
if (version_compare($this->laravel->version(), '5.2.0', '<')) { |
|
218
|
218
|
$userModel = config('auth.model'); |
|
219
|
219
|
$user = $userModel::find((int) $actAs); |
|
@@ -255,9 +255,9 @@ discard block |
|
|
block discarded – undo |
|
255
|
255
|
if (in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $route->getUri()) || in_array($middleware, $route->middleware())) { |
|
256
|
256
|
if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
|
257
|
257
|
$parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse); |
|
258
|
|
- $this->info('Processed route: ['.implode(',', $route->getMethods()).'] '.$route->getUri()); |
|
|
258
|
+ $this->info('Processed route: [' . implode(',', $route->getMethods()) . '] ' . $route->getUri()); |
|
259
|
259
|
} else { |
|
260
|
|
- $this->warn('Skipping route: ['.implode(',', $route->getMethods()).'] '.$route->getUri()); |
|
|
260
|
+ $this->warn('Skipping route: [' . implode(',', $route->getMethods()) . '] ' . $route->getUri()); |
|
261
|
261
|
} |
|
262
|
262
|
} |
|
263
|
263
|
} |
|
@@ -284,7 +284,7 @@ discard block |
|
|
block discarded – undo |
|
284
|
284
|
$parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse); |
|
285
|
285
|
$this->info('Processed route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri()); |
|
286
|
286
|
} else { |
|
287
|
|
- $this->warn('Skipping route: ['.implode(',', $route->getMethods()).'] '.$route->uri()); |
|
|
287
|
+ $this->warn('Skipping route: [' . implode(',', $route->getMethods()) . '] ' . $route->uri()); |
|
288
|
288
|
} |
|
289
|
289
|
} |
|
290
|
290
|
} |
|
@@ -299,7 +299,7 @@ discard block |
|
|
block discarded – undo |
|
299
|
299
|
*/ |
|
300
|
300
|
private function isValidRoute($route) |
|
301
|
301
|
{ |
|
302
|
|
- return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
|
302
|
+ return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
303
|
303
|
} |
|
304
|
304
|
|
|
305
|
305
|
/** |
|
@@ -316,7 +316,7 @@ discard block |
|
|
block discarded – undo |
|
316
|
316
|
$phpdoc = new DocBlock($comment); |
|
317
|
317
|
|
|
318
|
318
|
return collect($phpdoc->getTags()) |
|
319
|
|
- ->filter(function ($tag) use ($route) { |
|
|
319
|
+ ->filter(function($tag) use ($route) { |
|
320
|
320
|
return $tag->getName() === 'hideFromAPIDocumentation'; |
|
321
|
321
|
}) |
|
322
|
322
|
->isEmpty(); |