Skip to content

Commit

Permalink
feat: custom pages support (#547)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* refactor: move code out of YAML and into bin/ script

* fix: lint fixes

Co-authored-by: Kanad Gupta <[email protected]>

Co-authored-by: Ryan Park <[email protected]>

Co-authored-by: Ryan Park <[email protected]>
  • Loading branch information
kanadgupta and RyanGWU82 authored Jul 28, 2022
1 parent d600ef4 commit af61f7e
Show file tree
Hide file tree
Showing 20 changed files with 972 additions and 57 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,26 @@ This command also has a dry run mode, which can be useful for initial setup and
rdme changelogs:single path-to-markdown-file
```

### Custom Pages

#### Syncing a Folder of Custom Pages to ReadMe

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.

Passing in a path to a directory will also sync any HTML/Markdown files that are located in subdirectories.

```sh
rdme custompages path-to-markdown-files
```

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).

#### Syncing a Single Custom Page to ReadMe

```sh
rdme custompages:single path-to-markdown-file
```

### Versions

#### Get All Versions Associated With Your Project
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: This is the custom page title
---
Body
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: This is another custom page title
---
Another body
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Body
6 changes: 6 additions & 0 deletions __tests__/__fixtures__/custompages/failure-docs/new-doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
htmlmode: true
title: This is the custom page title
---

Body
5 changes: 5 additions & 0 deletions __tests__/__fixtures__/custompages/new-docs-html/new-doc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
hidden: false
---

<div></div>
6 changes: 6 additions & 0 deletions __tests__/__fixtures__/custompages/new-docs/new-doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
htmlmode: true
title: This is the custom page title
---

Body
7 changes: 7 additions & 0 deletions __tests__/__fixtures__/custompages/slug-docs/new-doc-slug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
htmlmode: true
title: This is the custom page title
slug: marc-actually-wrote-a-test
---

Body
22 changes: 14 additions & 8 deletions __tests__/cmds/changelogs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ describe('rdme changelogs', () => {
});

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

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

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

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

it('should error if the argument is not a markdown file', async () => {
await expect(changelogsSingle.run({ key, version: '1.0.0', filePath: 'not-a-markdown-file' })).rejects.toThrow(
'The file path specified is not a markdown file.'
it('should error if the argument is not a Markdown file', async () => {
await expect(changelogsSingle.run({ key, filePath: 'not-a-markdown-file' })).rejects.toThrow(
'The file path specified is not a Markdown file.'
);
});

it('should support .markdown files but error if file path cannot be found', async () => {
await expect(changelogsSingle.run({ key, filePath: 'non-existent-file.markdown' })).rejects.toThrow(
'ENOENT: no such file or directory'
);
});

Expand Down
Loading

0 comments on commit af61f7e

Please sign in to comment.