Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ As an optional parameter, you can use `--location` to tell the update command wh
If you wish to automatically add the same content to the docs every time you generate, you can add a `prepend.md` and/or `append.md` file to the source folder, and they will be included above and below the generated documentation.

**File locations:**
- `public/docs/source/prepend.md`
- `public/docs/source/append.md`
- `public/docs/source/prepend.md` - Will be added after the front matter and info text
- `public/docs/source/append.md` - Will be added at the end of the document

## Skip single routes

Expand Down
3 changes: 3 additions & 0 deletions tests/Fixtures/append.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Appended Markdown

This markdown should be added to the end of generated docs
3 changes: 3 additions & 0 deletions tests/Fixtures/prepend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Prepended Markdown

This markdown should be added to the start of generated docs
23 changes: 23 additions & 0 deletions tests/GenerateDocumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,29 @@ public function testGeneratedMarkdownFileIsCorrect()
$this->assertFilesHaveSameContent($fixtureMarkdown, $compareMarkdown);
}

public function testCanPrependAndAppendDataToGeneratedMarkdown()
{
RouteFacade::get('/api/test', TestController::class.'@parseMethodDescription');
RouteFacade::get('/api/fetch', TestController::class.'@fetchRouteResponse');

$this->artisan('api:generate', [
'--routePrefix' => 'api/*',
]);

$prependMarkdown = __DIR__.'/Fixtures/prepend.md';
$appendMarkdown = __DIR__.'/Fixtures/append.md';
copy($prependMarkdown, __DIR__.'/../public/docs/source/prepend.md');
copy($appendMarkdown, __DIR__.'/../public/docs/source/append.md');

$this->artisan('api:generate', [
'--routePrefix' => 'api/*',
]);

$generatedMarkdown = __DIR__.'/../public/docs/source/index.md';
$this->assertContainsRaw($this->getFileContents($prependMarkdown), $this->getFileContents($generatedMarkdown));
$this->assertContainsRaw($this->getFileContents($appendMarkdown), $this->getFileContents($generatedMarkdown));
}

public function testAddsBindingsToGetRouteRules()
{
RouteFacade::get('/api/test/{foo}', TestController::class.'@addRouteBindingsToRequestClass');
Expand Down