|
@@ -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->sourceOutputPath); |
|
150
|
150
|
|
|
151
|
|
- if (! is_dir($this->sourceOutputPath)) { |
|
|
151
|
+ if (!is_dir($this->sourceOutputPath)) { |
|
152
|
152
|
$documentarian = new Documentarian(); |
|
153
|
153
|
$documentarian->create($this->sourceOutputPath); |
|
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) |
|
@@ -258,7 +258,7 @@ discard block |
|
|
block discarded – undo |
|
258
|
258
|
protected function copyAssetsFromSourceFolderToPublicFolder(): void |
|
259
|
259
|
{ |
|
260
|
260
|
$publicPath = $this->config->get('output_folder') ?? 'public/docs'; |
|
261
|
|
- if (! is_dir($publicPath)) { |
|
|
261
|
+ if (!is_dir($publicPath)) { |
|
262
|
262
|
mkdir($publicPath, 0777, true); |
|
263
|
263
|
mkdir("{$publicPath}/css"); |
|
264
|
264
|
mkdir("{$publicPath}/js"); |
|
@@ -281,7 +281,7 @@ discard block |
|
|
block discarded – undo |
|
281
|
281
|
$assetPath = str_replace('public', '', $this->config->get('output_folder')); |
|
282
|
282
|
|
|
283
|
283
|
// Move output to resources/views |
|
284
|
|
- if (! is_dir($this->outputPath)) { |
|
|
284
|
+ if (!is_dir($this->outputPath)) { |
|
285
|
285
|
mkdir($this->outputPath); |
|
286
|
286
|
} |
|
287
|
287
|
rename("{$this->sourceOutputPath}/index.html", "$this->outputPath/index.blade.php"); |