Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(v2): docs plugin stability improvement (100% test coverage) #1912

Merged
merged 7 commits into from
Oct 29, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG-2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Prioritize `@docusaurus/core` dependencies/ node_modules over user's node_modules. This fix a bug whereby if user has core-js@3 on its own node_modules but docusaurus depends on core-js@2, we previously encounter `Module not found: core-js/modules/xxxx` (because core-js@3 doesn't have that).
Another example is if user installed webpack@3 but docusaurus depends on webpack@4.
- Added code block line highlighting feature (thanks @lex111)! If you have previously swizzled the `CodeBlock` theme component, it is recommended to update your source code to have this feature.
- Fix a bug where docs plugin add `/docs` route even if docs folder is empty. We also improved docs plugin test coverage to 100% for stability before working on docs versioning.

## 2.0.0-alpha.31

Expand Down
21 changes: 12 additions & 9 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,23 @@

const path = require('path');

const ignorePatterns = [
'/node_modules/',
'__fixtures__',
'/packages/docusaurus/lib',
'/packages/docusaurus-utils/lib',
'/packages/docusaurus-plugin-content-blog/lib',
'/packages/docusaurus-plugin-content-docs/lib',
'/packages/docusaurus-plugin-content-pages/lib',
];

module.exports = {
rootDir: path.resolve(__dirname),
verbose: true,
testURL: 'http://localhost/',
testEnvironment: 'node',
testPathIgnorePatterns: [
'/node_modules/',
'__fixtures__',
'/packages/docusaurus/lib',
'/packages/docusaurus-utils/lib',
'/packages/docusaurus-plugin-content-blog/lib',
'/packages/docusaurus-plugin-content-docs-legacy/lib',
'/packages/docusaurus-plugin-content-pages/lib',
],
testPathIgnorePatterns: ignorePatterns,
coveragePathIgnorePatterns: ignorePatterns,
transform: {
'^.+\\.[jt]sx?$': 'babel-jest',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
id: hello/super
---

Lorem
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = {
title: 'My Site',
tagline: 'The tagline of my site',
url: 'https://your-docusaurus-test-site.com',
baseUrl: '/',
favicon: 'img/favicon.ico',
organizationName: 'facebook', // Usually your GitHub org/user name.
projectName: 'docusaurus', // Usually your repo name.
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"docs": {
"Test": [
{
"type": "category",
"label": "Category Label",
"items": "doc1"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"docs": {
"Test": [
"foo/bar",
"foo/baz",
{
"type": "category",
"label": "category",
"href": "https://github.com"
},
{
"type": "ref",
"id": "hello"
}
],
"Guides": [
"hello"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
id: lorem
custom_edit_url: https://github.com/customUrl/docs/lorem.md
---

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

module.exports = {
title: 'My Site',
tagline: 'The tagline of my site',
url: 'https://your-docusaurus-test-site.com',
baseUrl: '/',
favicon: 'img/favicon.ico',
organizationName: 'facebook', // Usually your GitHub org/user name.
projectName: 'docusaurus', // Usually your repo name.
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"docs": {
"Test": [
{
"type": "category",
"label": "foo",
"items": ["foo/bar", "foo/baz"]
},
{
"type": "link",
"label": "Github",
"href": "https://github.com"
},
{
"type": "ref",
"id": "hello"
}
],
"Guides": [
"hello"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"docs": {
"Test": [
"goku"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`simple website content 1`] = `
Object {
"docs": Array [
Object {
"items": Array [
Object {
"items": Array [
Object {
"href": "/docs/foo/bar",
"label": "Bar",
"type": "link",
},
Object {
"href": "/docs/foo/baz",
"label": "baz",
"type": "link",
},
],
"label": "foo",
"type": "category",
},
Object {
"href": "https://github.com",
"label": "Github",
"type": "link",
},
Object {
"href": "/docs/hello",
"label": "Hello, World !",
"type": "link",
},
],
"label": "Test",
"type": "category",
},
Object {
"items": Array [
Object {
"href": "/docs/hello",
"label": "Hello, World !",
"type": "link",
},
],
"label": "Guides",
"type": "category",
},
],
}
`;

exports[`simple website content 2`] = `
Array [
Object {
"component": "@theme/DocPage",
"modules": Object {
"docsMetadata": "@docusaurus-plugin-content-docs/docs-b5f.json",
},
"path": "/docs",
"routes": Array [
Object {
"component": "@theme/DocItem",
"exact": true,
"modules": Object {
"content": "@site/docs/permalink.md",
"metadata": "@docusaurus-plugin-content-docs/docs-endiliey-permalink-086.json",
},
"path": "/docs/endiliey/permalink",
},
Object {
"component": "@theme/DocItem",
"exact": true,
"modules": Object {
"content": "@site/docs/foo/bar.md",
"metadata": "@docusaurus-plugin-content-docs/docs-foo-bar-cef.json",
},
"path": "/docs/foo/bar",
},
Object {
"component": "@theme/DocItem",
"exact": true,
"modules": Object {
"content": "@site/docs/foo/baz.md",
"metadata": "@docusaurus-plugin-content-docs/docs-foo-baz-dd9.json",
},
"path": "/docs/foo/baz",
},
Object {
"component": "@theme/DocItem",
"exact": true,
"modules": Object {
"content": "@site/docs/hello.md",
"metadata": "@docusaurus-plugin-content-docs/docs-hello-da2.json",
},
"path": "/docs/hello",
},
Object {
"component": "@theme/DocItem",
"exact": true,
"modules": Object {
"content": "@site/docs/lorem.md",
"metadata": "@docusaurus-plugin-content-docs/docs-lorem-17b.json",
},
"path": "/docs/lorem",
},
],
},
]
`;
Loading