This repository has been archived by the owner on Nov 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: render script if typedoc is >=0.24.5
- Loading branch information
1 parent
df1becc
commit ea31790
Showing
8 changed files
with
161 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`load renders markup on "body.end" for typedoc v0.24.4 1`] = ` | ||
{ | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [], | ||
"props": { | ||
"html": "style", | ||
}, | ||
"tag": [Function], | ||
}, | ||
], | ||
"props": null, | ||
"tag": "style", | ||
}, | ||
{ | ||
"children": [ | ||
{ | ||
"children": [], | ||
"props": { | ||
"html": "(function(){scriptundefined();})();", | ||
}, | ||
"tag": [Function], | ||
}, | ||
], | ||
"props": null, | ||
"tag": "script", | ||
}, | ||
], | ||
"props": null, | ||
"tag": Symbol(), | ||
} | ||
`; | ||
|
||
exports[`load renders markup on "body.end" for typedoc v0.24.5 1`] = ` | ||
{ | ||
"children": [ | ||
{ | ||
"children": [ | ||
{ | ||
"children": [], | ||
"props": { | ||
"html": "style", | ||
}, | ||
"tag": [Function], | ||
}, | ||
], | ||
"props": null, | ||
"tag": "style", | ||
}, | ||
false, | ||
], | ||
"props": null, | ||
"tag": Symbol(), | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,35 @@ | ||
import type { Application } from 'typedoc'; | ||
import { Application } from 'typedoc'; | ||
|
||
import { load } from '../src/index'; | ||
|
||
jest.mock('../src/script', () => 'script'); | ||
jest.mock('../src/style', () => 'style'); | ||
|
||
const { VERSION } = Application; | ||
|
||
afterAll(() => { | ||
Application.VERSION = VERSION; | ||
}); | ||
|
||
describe('load', () => { | ||
it('calls hook "body.end" with callback', () => { | ||
const app = { | ||
renderer: { | ||
hooks: { | ||
on: jest.fn(), | ||
it.each(['0.24.4', '0.24.5'])( | ||
'renders markup on "body.end" for typedoc v%s', | ||
(version) => { | ||
Application.VERSION = version; | ||
const app = { | ||
renderer: { | ||
hooks: { | ||
on: jest.fn(), | ||
}, | ||
}, | ||
}, | ||
}; | ||
expect(load(app as unknown as Application)).toBe(undefined); | ||
expect(app.renderer.hooks.on).toBeCalledTimes(1); | ||
expect(app.renderer.hooks.on).toBeCalledWith( | ||
'body.end', | ||
expect.any(Function) | ||
); | ||
expect(app.renderer.hooks.on.mock.calls[0][1]()).toBeTruthy(); | ||
}); | ||
}; | ||
expect(load(app as unknown as Application)).toBe(undefined); | ||
expect(app.renderer.hooks.on).toBeCalledTimes(1); | ||
expect(app.renderer.hooks.on).toBeCalledWith( | ||
'body.end', | ||
expect.any(Function) | ||
); | ||
expect(app.renderer.hooks.on.mock.calls[0][1]()).toMatchSnapshot(); | ||
} | ||
); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
DOCS_DIRECTORY='docs' | ||
|
||
npm run docs | ||
|
||
# https://developers.cloudflare.com/pages/platform/build-configuration/#environment-variables | ||
if [[ $CF_PAGES == '1' ]]; then | ||
# https://community.cloudflare.com/t/functions-dir-is-ignored-in-deploy/438211 | ||
# https://github.com/cloudflare/wrangler2/issues/2240#issuecomment-1343406897 | ||
FUNCTIONS='functions/' | ||
RENAMED_FUNCTIONS='function/' | ||
FUNCTIONS_DIRECTORY="$DOCS_DIRECTORY/$FUNCTIONS" | ||
RENAMED_FUNCTIONS_DIRECTORY="$DOCS_DIRECTORY/$RENAMED_FUNCTIONS" | ||
|
||
mv $FUNCTIONS_DIRECTORY $RENAMED_FUNCTIONS_DIRECTORY | ||
|
||
if [[ $(uname) == 'Linux' ]]; then | ||
sed -i "s|$FUNCTIONS|$RENAMED_FUNCTIONS|g" $DOCS_DIRECTORY/*.html | ||
sed -i "s|$FUNCTIONS|$RENAMED_FUNCTIONS|g" $DOCS_DIRECTORY/assets/search.js | ||
elif [[ $(uname) == 'Darwin' ]]; then | ||
sed -i '' "s|$FUNCTIONS|$RENAMED_FUNCTIONS|g" $DOCS_DIRECTORY/*.html | ||
sed -i '' "s|$FUNCTIONS|$RENAMED_FUNCTIONS|g" $DOCS_DIRECTORY/assets/search.js | ||
fi | ||
|
||
echo "Renamed $FUNCTIONS_DIRECTORY to $RENAMED_FUNCTIONS_DIRECTORY" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters