|
@@ -114,8 +114,8 @@ discard block |
|
|
block discarded – undo |
|
114
|
114
|
$generatedDocumentation = file_get_contents($targetFile); |
|
115
|
115
|
$compareDocumentation = file_get_contents($compareFile); |
|
116
|
116
|
|
|
117
|
|
- $parsedRouteOutput->transform(function (Collection $routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
118
|
|
- return $routeGroup->transform(function (array $route) use ($generatedDocumentation, $compareDocumentation) { |
|
|
117
|
+ $parsedRouteOutput->transform(function(Collection $routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
|
118
|
+ return $routeGroup->transform(function(array $route) use ($generatedDocumentation, $compareDocumentation) { |
|
119
|
119
|
if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
120
|
120
|
$routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
121
|
121
|
if ($routeDocumentationChanged === false || $this->forceIt) { |
|
@@ -148,7 +148,7 @@ discard block |
|
|
block discarded – undo |
|
148
|
148
|
|
|
149
|
149
|
$this->output->info('Writing index.md and source files to: ' . $this->getSourceOutputPath()); |
|
150
|
150
|
|
|
151
|
|
- if (! is_dir($this->getSourceOutputPath())) { |
|
|
151
|
+ if (!is_dir($this->getSourceOutputPath())) { |
|
152
|
152
|
$documentarian = new Documentarian(); |
|
153
|
153
|
$documentarian->create($this->getSourceOutputPath()); |
|
154
|
154
|
} |
|
@@ -174,14 +174,14 @@ discard block |
|
|
block discarded – undo |
|
174
|
174
|
|
|
175
|
175
|
public function generateMarkdownOutputForEachRoute(Collection $parsedRoutes, array $settings): Collection |
|
176
|
176
|
{ |
|
177
|
|
- $parsedRouteOutput = $parsedRoutes->map(function (Collection $routeGroup) use ($settings) { |
|
178
|
|
- return $routeGroup->map(function (array $route) use ($settings) { |
|
179
|
|
- if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) { |
|
|
177
|
+ $parsedRouteOutput = $parsedRoutes->map(function(Collection $routeGroup) use ($settings) { |
|
|
178
|
+ return $routeGroup->map(function(array $route) use ($settings) { |
|
|
179
|
+ if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) { |
|
180
|
180
|
// Set content type if the user forgot to set it |
|
181
|
181
|
$route['headers']['Content-Type'] = 'application/json'; |
|
182
|
182
|
} |
|
183
|
183
|
|
|
184
|
|
- $hasRequestOptions = ! empty($route['headers']) || ! empty($route['cleanQueryParameters']) || ! empty($route['cleanBodyParameters']); |
|
|
184
|
+ $hasRequestOptions = !empty($route['headers']) || !empty($route['cleanQueryParameters']) || !empty($route['cleanBodyParameters']); |
|
185
|
185
|
$route['output'] = (string) view('apidoc::partials.route') |
|
186
|
186
|
->with('hasRequestOptions', $hasRequestOptions) |
|
187
|
187
|
->with('route', $route) |
|
@@ -203,7 +203,7 @@ discard block |
|
|
block discarded – undo |
|
203
|
203
|
|
|
204
|
204
|
$collection = $this->generatePostmanCollection($parsedRoutes); |
|
205
|
205
|
if ($this->isStatic) { |
|
206
|
|
- $collectionPath = $this->getOutputPath()."/collection.json"; |
|
|
206
|
+ $collectionPath = $this->getOutputPath() . "/collection.json"; |
|
207
|
207
|
file_put_contents($collectionPath, $collection); |
|
208
|
208
|
} else { |
|
209
|
209
|
$storageInstance = Storage::disk($this->config->get('storage')); |
|
@@ -258,15 +258,15 @@ discard block |
|
|
block discarded – undo |
|
258
|
258
|
protected function copyAssetsFromSourceFolderToPublicFolder(): void |
|
259
|
259
|
{ |
|
260
|
260
|
$publicPath = base_path($this->config->get('output_folder') ?? base_path('public/docs')); |
|
261
|
|
- if (! is_dir($publicPath)) { |
|
|
261
|
+ if (!is_dir($publicPath)) { |
|
262
|
262
|
mkdir($publicPath, 0777, true); |
|
263
|
263
|
} |
|
264
|
264
|
|
|
265
|
|
- if (! is_dir("{$publicPath}/css")) { |
|
|
265
|
+ if (!is_dir("{$publicPath}/css")) { |
|
266
|
266
|
mkdir("{$publicPath}/css", 0777, true); |
|
267
|
267
|
} |
|
268
|
268
|
|
|
269
|
|
- if (! is_dir("{$publicPath}/js")) { |
|
|
269
|
+ if (!is_dir("{$publicPath}/js")) { |
|
270
|
270
|
mkdir("{$publicPath}/js", 0777, true); |
|
271
|
271
|
} |
|
272
|
272
|
|
|
@@ -289,13 +289,13 @@ discard block |
|
|
block discarded – undo |
|
289
|
289
|
$outputPath = $this->getOutputPath(); |
|
290
|
290
|
if ($this->isStatic) { |
|
291
|
291
|
// Move output (index.html, css/style.css and js/all.js) to public/docs |
|
292
|
|
- rename($this->getSourceOutputPath()."/index.html", "{$outputPath}/index.html"); |
|
|
292
|
+ rename($this->getSourceOutputPath() . "/index.html", "{$outputPath}/index.html"); |
|
293
|
293
|
} else { |
|
294
|
294
|
// Move output to resources/views |
|
295
|
|
- if (! is_dir($outputPath)) { |
|
|
295
|
+ if (!is_dir($outputPath)) { |
|
296
|
296
|
mkdir($outputPath); |
|
297
|
297
|
} |
|
298
|
|
- rename($this->getSourceOutputPath()."/index.html", "$outputPath/index.blade.php"); |
|
|
298
|
+ rename($this->getSourceOutputPath() . "/index.html", "$outputPath/index.blade.php"); |
|
299
|
299
|
$contents = file_get_contents("$outputPath/index.blade.php"); |
|
300
|
300
|
// |
|
301
|
301
|
$contents = str_replace('href="css/style.css"', 'href="{{ asset(\'/docs/css/style.css\') }}"', $contents); |
|
@@ -317,7 +317,7 @@ discard block |
|
|
block discarded – undo |
|
317
|
317
|
|
|
318
|
318
|
$this->moveOutputFromSourceFolderToTargetFolder(); |
|
319
|
319
|
|
|
320
|
|
- $this->output->info("Wrote HTML documentation to: ".$this->getOutputPath()); |
|
|
320
|
+ $this->output->info("Wrote HTML documentation to: " . $this->getOutputPath()); |
|
321
|
321
|
} |
|
322
|
322
|
|
|
323
|
323
|
protected function getOutputPath(): string |