Skip to content

Commit 312d4df

Browse files
authored
Merge pull request #331 from shalvah/prepend-append-markdown
Add tests for prepending and appending markdown (#191, PR264)
2 parents 716c00c + 0fa6c15 commit 312d4df

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ As an optional parameter, you can use `--location` to tell the update command wh
244244
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.
245245

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

250250
## Skip single routes
251251

tests/Fixtures/append.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Appended Markdown
2+
3+
This markdown should be added to the end of generated docs

tests/Fixtures/prepend.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Prepended Markdown
2+
3+
This markdown should be added to the start of generated docs

tests/GenerateDocumentationTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,29 @@ public function testGeneratedMarkdownFileIsCorrect()
143143
$this->assertFilesHaveSameContent($fixtureMarkdown, $compareMarkdown);
144144
}
145145

146+
public function testCanPrependAndAppendDataToGeneratedMarkdown()
147+
{
148+
RouteFacade::get('/api/test', TestController::class.'@parseMethodDescription');
149+
RouteFacade::get('/api/fetch', TestController::class.'@fetchRouteResponse');
150+
151+
$this->artisan('api:generate', [
152+
'--routePrefix' => 'api/*',
153+
]);
154+
155+
$prependMarkdown = __DIR__.'/Fixtures/prepend.md';
156+
$appendMarkdown = __DIR__.'/Fixtures/append.md';
157+
copy($prependMarkdown, __DIR__.'/../public/docs/source/prepend.md');
158+
copy($appendMarkdown, __DIR__.'/../public/docs/source/append.md');
159+
160+
$this->artisan('api:generate', [
161+
'--routePrefix' => 'api/*',
162+
]);
163+
164+
$generatedMarkdown = __DIR__.'/../public/docs/source/index.md';
165+
$this->assertContainsRaw($this->getFileContents($prependMarkdown), $this->getFileContents($generatedMarkdown));
166+
$this->assertContainsRaw($this->getFileContents($appendMarkdown), $this->getFileContents($generatedMarkdown));
167+
}
168+
146169
public function testAddsBindingsToGetRouteRules()
147170
{
148171
RouteFacade::get('/api/test/{foo}', TestController::class.'@addRouteBindingsToRequestClass');

0 commit comments

Comments
 (0)