Skip to content

Commit af61f7e

Browse files
feat: custom pages support (#547)
* chore: create custompages cmd category * test: fixtures * feat: initial pass at commands as part of this, we had to slightly refactor the pushDoc function to augment the data to support the HTML file handling required by the custompages API * test: initial pass at tests * docs: update README usage * test: remove unused version params, stricter error checks * fix(docs/single): support files with `.markdown` extension (#549) * fix: support files with .markdown extension * test: random cleanup fixing typo, removing unused version param, stricter error checks * chore: capitalize Markdown * chore: lowercase all file extension checks * refactor: DRY some docs logic (#550) * fix: support files with .markdown extension * test: random cleanup fixing typo, removing unused version param, stricter error checks * refactor: DRY some docs logic * feat: add retag-release workflow to add a vX.Y.Z tag for our GitHub Action (#545) * feat: add retag-release workflow to add a vX.Y.Z tag for our GitHub Action * Update .github/workflows/retag-release.yaml Co-authored-by: Kanad Gupta <kgupta@umn.edu> * refactor: move code out of YAML and into bin/ script * fix: lint fixes Co-authored-by: Kanad Gupta <kgupta@umn.edu> Co-authored-by: Ryan Park <ryan@ryanpark.org> Co-authored-by: Ryan Park <ryan@ryanpark.org>
1 parent d600ef4 commit af61f7e

File tree

20 files changed

+972
-57
lines changed

20 files changed

+972
-57
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,26 @@ This command also has a dry run mode, which can be useful for initial setup and
191191
rdme changelogs:single path-to-markdown-file
192192
```
193193

194+
### Custom Pages
195+
196+
#### Syncing a Folder of Custom Pages to ReadMe
197+
198+
Custom Pages has support for both Markdown and HTML files. These files will require YAML front matter with certain ReadMe documentation attributes. Check out [our docs](https://docs.readme.com/docs/rdme#markdown-file-setup) for more info on setting up your front matter.
199+
200+
Passing in a path to a directory will also sync any HTML/Markdown files that are located in subdirectories.
201+
202+
```sh
203+
rdme custompages path-to-markdown-files
204+
```
205+
206+
This command also has a dry run mode, which can be useful for initial setup and debugging. You can read more about dry run mode [in our docs](https://docs.readme.com/docs/rdme#dry-run-mode).
207+
208+
#### Syncing a Single Custom Page to ReadMe
209+
210+
```sh
211+
rdme custompages:single path-to-markdown-file
212+
```
213+
194214
### Versions
195215

196216
#### Get All Versions Associated With Your Project

__tests__/__fixtures__/custompages/existing-docs/not-a-markdown-file

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: This is the custom page title
3+
---
4+
Body
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
title: This is another custom page title
3+
---
4+
Another body
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Body
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
htmlmode: true
3+
title: This is the custom page title
4+
---
5+
6+
Body
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
hidden: false
3+
---
4+
5+
<div></div>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
htmlmode: true
3+
title: This is the custom page title
4+
---
5+
6+
Body
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
htmlmode: true
3+
title: This is the custom page title
4+
slug: marc-actually-wrote-a-test
5+
---
6+
7+
Body

__tests__/cmds/changelogs.test.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ describe('rdme changelogs', () => {
3232
});
3333

3434
it('should error if no folder provided', () => {
35-
return expect(changelogs.run({ key, version: '1.0.0' })).rejects.toThrow(
35+
return expect(changelogs.run({ key })).rejects.toThrow(
3636
'No folder provided. Usage `rdme changelogs <folder> [options]`.'
3737
);
3838
});
3939

40-
it('should error if the argument isnt a folder', () => {
41-
return expect(changelogs.run({ key, version: '1.0.0', folder: 'not-a-folder' })).rejects.toThrow(
40+
it('should error if the argument is not a folder', () => {
41+
return expect(changelogs.run({ key, folder: 'not-a-folder' })).rejects.toThrow(
4242
"ENOENT: no such file or directory, scandir 'not-a-folder'"
4343
);
4444
});
4545

4646
it('should error if the folder contains no markdown files', () => {
47-
return expect(changelogs.run({ key, version: '1.0.0', folder: '.github/workflows' })).rejects.toThrow(
47+
return expect(changelogs.run({ key, folder: '.github/workflows' })).rejects.toThrow(
4848
'We were unable to locate Markdown files in .github/workflows.'
4949
);
5050
});
@@ -356,14 +356,20 @@ describe('rdme changelogs:single', () => {
356356
});
357357

358358
it('should error if no file path provided', () => {
359-
return expect(changelogsSingle.run({ key, version: '1.0.0' })).rejects.toThrow(
359+
return expect(changelogsSingle.run({ key })).rejects.toThrow(
360360
'No file path provided. Usage `rdme changelogs:single <file> [options]`.'
361361
);
362362
});
363363

364-
it('should error if the argument is not a markdown file', async () => {
365-
await expect(changelogsSingle.run({ key, version: '1.0.0', filePath: 'not-a-markdown-file' })).rejects.toThrow(
366-
'The file path specified is not a markdown file.'
364+
it('should error if the argument is not a Markdown file', async () => {
365+
await expect(changelogsSingle.run({ key, filePath: 'not-a-markdown-file' })).rejects.toThrow(
366+
'The file path specified is not a Markdown file.'
367+
);
368+
});
369+
370+
it('should support .markdown files but error if file path cannot be found', async () => {
371+
await expect(changelogsSingle.run({ key, filePath: 'non-existent-file.markdown' })).rejects.toThrow(
372+
'ENOENT: no such file or directory'
367373
);
368374
});
369375

0 commit comments

Comments
 (0)