-
Notifications
You must be signed in to change notification settings - Fork 132
New SDK Reference Website #289
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
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
3b0387c
init docusaurus
jooohhn 7a5a808
remove blog
jooohhn 4d97a2b
replace image assets
jooohhn c84980c
update footer
jooohhn 883884c
update navbar
jooohhn a11afd0
update docusaurus config
jooohhn 18db157
edit landing page
jooohhn fd7f3d0
change css theme
jooohhn b567052
add amplitude-js docs
jooohhn de6f1b8
add jsdoc-to-markdown
jooohhn 5f4b6b8
add generate-jsdoc.js and prettier to format md output
jooohhn f5e8bff
Replace default docs with generated API docs
jooohhn 8becf23
remove footer content
jooohhn 64abe16
make sidebar uncollapsible
jooohhn aa7b2e6
add syntax highlight to examples
jooohhn 2693f94
change docusaurus target browsers
jooohhn de65cba
change docs to include constructor
jooohhn e980be2
make website docs only
jooohhn 832a1c4
change docs/ to website/
jooohhn fd7ae60
fix baseUrl config
jooohhn b914e95
Fix baseUrl problem with yarn serve
jooohhn 0813046
update readme
jooohhn 7030caa
delete autogenerated docs
jooohhn 5bb58fe
Add autogenerated docs to gitignore
jooohhn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,26 @@ | ||
| # Dependencies | ||
| /node_modules | ||
|
|
||
| # Production | ||
| /build | ||
|
|
||
| # Generated files | ||
| .docusaurus | ||
| .cache-loader | ||
|
|
||
| # Generated jsdoc markdown | ||
| docs/Amplitude.md | ||
| docs/AmplitudeClient.md | ||
| docs/Identify.md | ||
| docs/Revenue.md | ||
|
|
||
| # Misc | ||
| .DS_Store | ||
| .env.local | ||
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
|
|
||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* |
This file contains hidden or 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,33 @@ | ||
| # Website | ||
|
|
||
| The JavaScript SDK API Reference website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator. | ||
|
|
||
| ### Installation | ||
|
|
||
| Installation is automatically done when `yarn install` is ran from the base directory. | ||
|
|
||
| ### Generating `website/docs/` from `src/` | ||
|
|
||
| The website autogenerates markdown files of public classes and its contents using [generate-jsdoc.js](https://github.com/amplitude/Amplitude-JavaScript/blob/master/website/generate-jsdoc.js). | ||
|
|
||
| This is done by calling `yarn docs:generate-jsdoc` from the base directory. | ||
|
|
||
| ### Local Development Build | ||
|
|
||
| Run `yarn start` from this directory or `yarn docs:start` from the base directory. | ||
|
|
||
| Because of a bug with how Docusaurus handles `baseUrl` in `docusaurus.config.js`, you should open `localhost:3000/Amplitude-JavaScript` instead of the default `localhost:3000/` | ||
|
|
||
| ### Local Production Build | ||
|
|
||
| Similar to local development build process. This command generates static content into the `website/build/` directory and creates a server to serve it. | ||
|
|
||
| Run `yarn serve` from this directory or `yarn docs:serve` from the base directory. Then open `localhost:3000/Amplitude-JavaScript` | ||
|
|
||
| ### Deployment | ||
|
|
||
| ``` | ||
| $ GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy | ||
| ``` | ||
|
|
||
| This will create the production build and push it the `gh-pages` branch. |
This file contains hidden or 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,3 @@ | ||
| module.exports = { | ||
| presets: [require.resolve('@docusaurus/core/lib/babel/preset')], | ||
| }; |
This file contains hidden or 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,55 @@ | ||
| module.exports = { | ||
| title: 'Amplitude JS SDK Docs', | ||
| tagline: 'Amplitude JavaScript SDK', | ||
| url: 'https://amplitude.github.io', | ||
| baseUrl: '/Amplitude-JavaScript/', | ||
| onBrokenLinks: 'throw', | ||
| favicon: 'img/amp_favicon.ico', | ||
| organizationName: 'Amplitude', | ||
| projectName: 'Amplitude-JavaScript', | ||
| themeConfig: { | ||
| sidebarCollapsible: false, | ||
| navbar: { | ||
| logo: { | ||
| alt: 'Amplitude Logo', | ||
| src: 'img/amp_logo.svg', | ||
| }, | ||
| hideOnScroll: true, | ||
| items: [ | ||
| { | ||
| href: 'https://github.com/amplitude/Amplitude-JavaScript/', | ||
| label: 'GitHub', | ||
| position: 'left', | ||
| }, | ||
| ], | ||
| }, | ||
| footer: { | ||
| logo: { | ||
| alt: 'Amplitude Logo', | ||
| src: 'img/amp_logo.svg', | ||
| }, | ||
| copyright: `Copyright © ${new Date().getFullYear()} Amplitude, Inc.`, | ||
| }, | ||
| prism: { | ||
| defaultLanguage: 'javascript', | ||
| }, | ||
| }, | ||
| presets: [ | ||
| [ | ||
| '@docusaurus/preset-classic', | ||
| { | ||
| docs: { | ||
| homePageId: 'AmplitudeClient', | ||
| path: 'docs', | ||
| routeBasePath: '/', | ||
| sidebarPath: require.resolve('./sidebars.js'), | ||
| editUrl: | ||
| 'https://github.com/amplitude/Amplitude-JavaScript/website', | ||
| }, | ||
| theme: { | ||
| customCss: require.resolve('./src/css/custom.css'), | ||
| }, | ||
| }, | ||
| ], | ||
| ], | ||
| }; |
This file contains hidden or 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,77 @@ | ||
| const jsdoc2md = require("jsdoc-to-markdown"); | ||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
| const prettier = require("prettier"); | ||
| const publicFiles = [ | ||
| "amplitude-client.js", | ||
| "amplitude.js", | ||
| "identify.js", | ||
| "revenue.js", | ||
| ]; | ||
| const srcDir = path.join(__dirname, "../", "src"); | ||
| const outputDir = path.join(__dirname, "docs"); | ||
| function generateMarkdown(inputFile) { | ||
| const inputFilePath = path.join(srcDir, inputFile); | ||
| const data = jsdoc2md.getTemplateDataSync({ files: inputFilePath }); | ||
| const className = data.find((e) => e.kind === "class").name; | ||
| const filteredData = data.filter( | ||
| (e) => | ||
| e.kind === "constructor" || | ||
| (e.access === "public" && (e.kind === "function" || e.kind === "member")) | ||
| ); | ||
| const outputFilePath = path.join(outputDir, `${className}.md`); | ||
|
|
||
| const markdownOutput = filteredData | ||
| .map((item) => documentItem(item)) | ||
| .join("\n"); | ||
| fs.writeFileSync( | ||
| path.join(outputDir, `${className}.md`), | ||
| prettier.format(markdownOutput, { parser: "markdown" }) | ||
| ); | ||
| } | ||
|
|
||
| function documentItem(data) { | ||
| return `## \`${data.id}\` | ||
|
|
||
| ${data.examples ? documentExamples(data) : ""} | ||
|
|
||
| ${data.description || ""} | ||
|
|
||
| ${data.params ? documentParams(data) : ""} | ||
|
|
||
| ${data.returns ? documentReturn(data) : ""} | ||
| `; | ||
| } | ||
|
|
||
| function documentExamples(data) { | ||
| return `\`\`\` | ||
| ${data.examples} | ||
| \`\`\` | ||
| `; | ||
| } | ||
|
|
||
| function documentParams(data) { | ||
| const params = data.params.map( | ||
| (param) => `- \`${param.name}\` (\`${param.type.names[0]}\`) | ||
| ${param.description} | ||
| ` | ||
| ); | ||
| return `### Parameters | ||
| ${params.join("\n")} | ||
| `; | ||
| } | ||
|
|
||
| function documentReturn(data) { | ||
| return `### Return Value | ||
| - (\`${data.returns[0].type.names[0]}\`) | ||
| ${data.returns[0].description} | ||
| `; | ||
| } | ||
|
|
||
| if (!fs.existsSync(outputDir)) { | ||
| fs.mkdirSync(outputDir); | ||
| } | ||
|
|
||
| for (const file of publicFiles) { | ||
| generateMarkdown(file); | ||
| } |
This file contains hidden or 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,33 @@ | ||
| { | ||
| "name": "docs", | ||
| "version": "0.0.0", | ||
| "private": true, | ||
| "scripts": { | ||
| "docusaurus": "docusaurus", | ||
| "start": "docusaurus start", | ||
| "build": "docusaurus build", | ||
| "swizzle": "docusaurus swizzle", | ||
| "deploy": "docusaurus deploy", | ||
| "serve": "docusaurus build --out-dir build/Amplitude-JavaScript && yarn run docusaurus serve" | ||
| }, | ||
| "dependencies": { | ||
| "@docusaurus/core": "^2.0.0-alpha.61", | ||
| "@docusaurus/preset-classic": "^2.0.0-alpha.61", | ||
| "@mdx-js/react": "^1.5.8", | ||
| "clsx": "^1.1.1", | ||
| "react": "^16.8.4", | ||
| "react-dom": "^16.8.4" | ||
| }, | ||
| "browserslist": { | ||
| "production": [ | ||
| ">0.1%", | ||
| "not dead", | ||
| "not op_mini all" | ||
| ], | ||
| "development": [ | ||
| "last 2 chrome version", | ||
| "last 2 firefox version", | ||
| "last 2 safari version" | ||
| ] | ||
| } | ||
| } | ||
This file contains hidden or 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,5 @@ | ||
| module.exports = { | ||
| sidebar: { | ||
| 'API Reference': ['AmplitudeClient', 'Amplitude', 'Identify', 'Revenue'], | ||
| }, | ||
| }; |
This file contains hidden or 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,54 @@ | ||
| /* stylelint-disable docusaurus/copyright-header */ | ||
| /** | ||
| * Any CSS included here will be global. The classic template | ||
| * bundles Infima by default. Infima is a CSS framework designed to | ||
| * work well for content-centric websites. | ||
| */ | ||
|
|
||
| /* You can override the default Infima variables here. */ | ||
| :root { | ||
| --ifm-color-primary: #007fd2; | ||
| --ifm-color-primary-dark: #005488; | ||
| --ifm-color-primary-darker: #003b61; | ||
| --ifm-color-primary-darkest: #0c2a4b; | ||
| --ifm-color-primary-light: #48a4de; | ||
| --ifm-color-primary-lighter: #7bbee7; | ||
| --ifm-color-primary-lightest: #c6e2f4; | ||
| --ifm-code-font-size: 95%; | ||
| } | ||
|
|
||
| .docusaurus-highlight-code-line { | ||
| background-color: rgb(72, 77, 91); | ||
| display: block; | ||
| margin: 0 calc(-1 * var(--ifm-pre-padding)); | ||
| padding: 0 var(--ifm-pre-padding); | ||
| } | ||
|
|
||
| /* OG site color #10069f */ | ||
| /* logo color #007fd2 */ | ||
| /* sidebar dark #003b61 */ | ||
| /* sidebar darkest #0c2a4b */ | ||
| /* Sidebar text ##c6d0d9 */ | ||
|
|
||
| /* $cerulean-50: #f4faff; | ||
| $cerulean-100: #e4f1fa; | ||
| $cerulean-200: #c6e2f4; | ||
| $cerulean-300: #7bbee7; | ||
| $cerulean-400: #48a4de; | ||
| $cerulean-500: #007fd2; | ||
| $cerulean-600: #0065a5; | ||
| $cerulean-700: #005488; | ||
| $cerulean-800: #003b61; | ||
| $cerulean-900: #0c2a4b; | ||
| :export { | ||
| cerulean-50: $cerulean-50; | ||
| cerulean-100: $cerulean-100; | ||
| cerulean-200: $cerulean-200; | ||
| cerulean-300: $cerulean-300; | ||
| cerulean-400: $cerulean-400; | ||
| cerulean-500: $cerulean-500; | ||
| cerulean-600: $cerulean-600; | ||
| cerulean-700: $cerulean-700; | ||
| cerulean-800: $cerulean-800; | ||
| cerulean-900: $cerulean-900; | ||
| } */ |
This file contains hidden or 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,37 @@ | ||
| /* stylelint-disable docusaurus/copyright-header */ | ||
|
|
||
| /** | ||
| * CSS files with the .module.css suffix will be treated as CSS modules | ||
| * and scoped locally. | ||
| */ | ||
|
|
||
| .heroBanner { | ||
| padding: 4rem 0; | ||
| text-align: center; | ||
| position: relative; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| @media screen and (max-width: 966px) { | ||
| .heroBanner { | ||
| padding: 2rem; | ||
| } | ||
| } | ||
|
|
||
| .buttons { | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| } | ||
|
|
||
| .features { | ||
| display: flex; | ||
| align-items: center; | ||
| padding: 2rem 0; | ||
| width: 100%; | ||
| } | ||
|
|
||
| .featureImage { | ||
| height: 200px; | ||
| width: 200px; | ||
| } |
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how would you feel if docusarus did not run on port :3000 as default? :)