├── .eslintignore ├── .eslintrc.cjs ├── .github └── workflows │ └── test.yml ├── .gitignore ├── .markdownlintrc ├── .ocularrc.js ├── .prettierignore ├── .prettierrc.cjs ├── .travis.yml ├── LICENSE ├── README.md ├── dev-docs └── RFCs │ ├── README.md │ └── v1.0 │ └── gatsby-rfc.md ├── docs ├── BASEURL ├── README.md ├── table-of-contents.json └── wip │ └── gatsby-theme-ocular │ ├── README.md │ ├── get-started.md │ └── upgrade-guide.md ├── examples └── dev-tools │ ├── .eslintrc.js │ ├── .prettierrc.js │ ├── babel.config.js │ ├── dist │ ├── es5 │ │ ├── app.js │ │ └── app.js.map │ └── esm │ │ ├── app.js │ │ └── app.js.map │ ├── index.html │ ├── ocular-dev-tools.config.js │ ├── package.json │ ├── src │ └── app.js │ └── webpack.config.js ├── modules └── dev-tools │ ├── CHANGELOG.md │ ├── README.md │ ├── docs │ ├── README.md │ ├── api-reference │ │ ├── get-babel-config.md │ │ ├── get-eslint-config.md │ │ └── get-prettier-config.md │ ├── cli │ │ ├── ocular-bootstrap.md │ │ ├── ocular-build.md │ │ ├── ocular-bump.md │ │ ├── ocular-clean.md │ │ ├── ocular-lint.md │ │ ├── ocular-metrics.md │ │ ├── ocular-publish.md │ │ ├── ocular-test.md │ │ └── ocular-tsify.md │ ├── faq.md │ ├── upgrade-guide.md │ └── whats-new.md │ ├── package.json │ ├── scripts │ ├── bootstrap.js │ ├── bootstrap.sh │ ├── build.js │ ├── build.sh │ ├── bump.js │ ├── bundle.js │ ├── clean.js │ ├── clean.sh │ ├── lint.js │ ├── lint.sh │ ├── metrics.js │ ├── metrics.sh │ ├── publish.js │ ├── publish.sh │ ├── shell.js │ ├── test.js │ └── test.sh │ ├── src │ ├── build-cjs.ts │ ├── configuration │ │ ├── eslint-config-uber-es2015 │ │ │ ├── best-practices.json │ │ │ ├── ecmascript-6.json │ │ │ ├── eslintrc.json │ │ │ ├── miscellaneous.json │ │ │ └── stylistic-issues.json │ │ ├── eslint-config-uber-es5 │ │ │ ├── best-practices.json │ │ │ ├── errors.json │ │ │ ├── eslintrc.json │ │ │ ├── miscellaneous.json │ │ │ ├── node-js-and-common-js.json │ │ │ ├── strict-mode.json │ │ │ ├── stylistic-issues.json │ │ │ └── variables.json │ │ ├── eslint-config-uber-jsx │ │ │ ├── best-practices.json │ │ │ ├── eslintrc.json │ │ │ ├── miscellaneous.json │ │ │ └── stylistic-issues.json │ │ ├── get-babel-config.ts │ │ ├── get-esbuild-config.ts │ │ ├── get-eslint-config.ts │ │ ├── get-prettier-config.ts │ │ ├── index.ts │ │ └── vite.config.js │ ├── helpers │ │ ├── aliases.ts │ │ ├── cjs-register.cjs │ │ ├── esm-alias.ts │ │ ├── esm-register.ts │ │ ├── get-cjs-entry-points.ts │ │ ├── get-config.ts │ │ └── get-ocular-config.ts │ ├── index.ts │ ├── test.ts │ ├── ts-plugins │ │ ├── ts-transform-append-extension │ │ │ └── index.ts │ │ ├── ts-transform-inline-webgl-constants │ │ │ └── index.ts │ │ ├── ts-transform-remove-glsl-comments │ │ │ └── index.ts │ │ └── ts-transform-version-inline │ │ │ └── index.ts │ └── utils │ │ ├── types.ts │ │ └── utils.ts │ ├── templates │ ├── .eslintignore │ ├── .eslintrc.gatsby-todo │ ├── .nycrc │ ├── .prettierignore │ ├── .prettierrc │ └── tsconfig.json │ ├── test │ ├── index.ts │ ├── lib │ │ ├── configuration.spec.ts │ │ └── utils.spec.ts │ └── ts-plugins │ │ ├── test-transformer.ts │ │ ├── ts-transform-append-extension.spec.ts │ │ ├── ts-transform-inline-webgl-constants.spec.ts │ │ ├── ts-transform-remove-glsl-comments │ │ ├── index.spec.ts │ │ ├── test-case-0-expected.ts │ │ ├── test-case-0.ts │ │ ├── test-case-1-expected.ts │ │ ├── test-case-1.ts │ │ ├── test-case-2-expected.ts │ │ └── test-case-2.ts │ │ └── ts-transform-version-inline.spec.ts │ └── tsconfig.json ├── package.json ├── scripts └── remove-refs-to-unpm.pl ├── test ├── browser.ts ├── index.html ├── modules.ts └── node.ts ├── tsconfig.build.json ├── tsconfig.json ├── website ├── .eslintignore ├── .gitignore ├── gatsby-config.js ├── package.json ├── src │ ├── about.md │ ├── home.md │ └── theme.json └── static │ └── images │ ├── favicon.ico │ ├── hero.jpg │ ├── icon-custom.svg │ ├── icon-react.svg │ ├── icon-target.svg │ └── uber-logo.png └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | test/ 3 | test-case-*.ts 4 | -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | const {getESLintConfig} = require('ocular-dev-tools/configuration'); 2 | 3 | module.exports = getESLintConfig({ 4 | overrides: { 5 | parserOptions: { 6 | project: ['./tsconfig.json'] 7 | }, 8 | 9 | rules: { 10 | 'import/no-extraneous-dependencies': 0, 11 | 'import/no-unresolved': 0, 12 | 'no-console': 0, 13 | 'no-continue': 0, 14 | 'no-process-env': 0, 15 | 'no-process-exit': 0 16 | }, 17 | 18 | env: { 19 | node: true 20 | }, 21 | 22 | ignorePatterns: ['modules/gatsby-theme-ocular'] 23 | } 24 | }); 25 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: test 2 | 3 | # On every pull request, but only on push to master 4 | on: 5 | push: 6 | branches: 7 | - master 8 | pull_request: 9 | 10 | jobs: 11 | test: 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | node-version: [18] 16 | 17 | steps: 18 | - uses: actions/checkout@v2.1.1 19 | 20 | - uses: c-hive/gha-yarn-cache@v1 21 | 22 | - name: Set up Node ${{ matrix.node-version }} 23 | uses: actions/setup-node@v1 24 | with: 25 | node-version: ${{ matrix.node-version }} 26 | 27 | - name: Bootstrap 28 | run: | 29 | yarn bootstrap 30 | 31 | - name: Run tests 32 | run: | 33 | npm run lint 34 | npm run cover 35 | 36 | - name: Coveralls 37 | if: matrix.node-version == 18 38 | uses: coverallsapp/github-action@master 39 | with: 40 | github-token: ${{ secrets.GITHUB_TOKEN }} 41 | path-to-lcov: ${{ github.workspace }}/coverage/lcov.info -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | 4 | .idea/ 5 | .nx/ 6 | yarn-error.log 7 | .DS_Store 8 | .vscode/ 9 | website/dist 10 | website/.DS_Store 11 | website/node_modules 12 | website/yarn-error.log 13 | 14 | package-lock.json 15 | 16 | website-test/* 17 | 18 | .reify-cache 19 | modules/dev-tools/.alias.json 20 | coverage/ 21 | .nyc_output/ 22 | tsconfig.tsbuildinfo 23 | -------------------------------------------------------------------------------- /.markdownlintrc: -------------------------------------------------------------------------------- 1 | { 2 | "default": true, 3 | "colors": true, 4 | "line-length": false, 5 | "ul-style": {"style": "sublist"}, 6 | "no-duplicate-header": false, 7 | "no-inline-html": false, 8 | "no-hard-tabs": false, 9 | "whitespace": false 10 | } 11 | -------------------------------------------------------------------------------- /.ocularrc.js: -------------------------------------------------------------------------------- 1 | /** @typedef {import('ocular-dev-tools').OcularConfig} OcularConfig */ 2 | import {resolve} from 'path'; 3 | 4 | /** @type {OcularConfig} */ 5 | let ocularConfig = { 6 | typescript: { 7 | project: 'tsconfig.build.json' 8 | }, 9 | 10 | babel: false, 11 | 12 | lint: { 13 | paths: ['modules'] 14 | }, 15 | 16 | aliases: { 17 | test: resolve('./test') 18 | }, 19 | 20 | entry: { 21 | test: 'test/node.ts', 22 | 'test-browser': 'test/index.html', 23 | size: 'test/size/import-nothing.js' 24 | } 25 | }; 26 | 27 | export default ocularConfig; 28 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/dist*/**/*.js 2 | test-case-*.ts -------------------------------------------------------------------------------- /.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | const {getPrettierConfig} = require('ocular-dev-tools/configuration'); 2 | 3 | module.exports = getPrettierConfig(); 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | os: linux 3 | sudo: required 4 | dist: trusty 5 | addons: 6 | node_js: 7 | - '12' 8 | - '14' 9 | install: 10 | - yarn bootstrap 11 | script: 12 | - npm run test 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Uber Technologies, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ocular 2 | 3 | Ocular is a monorepo for development tools primarily designed for building github-based javascript frameworks. 4 | 5 | It currently contains: 6 | 7 | - `gatsby-theme-ocular` - A documentation generator packaged as a pluggable theme for gatsbyjs documentation generation system. 8 | - `ocular-dev-tools` - A set tools that packages up extensive installation and configuration of babel, webpack, lint, prettier and other state-of-the art JS build tools. 9 | -------------------------------------------------------------------------------- /dev-docs/RFCs/README.md: -------------------------------------------------------------------------------- 1 | # RFCs and Roadmaps (ocular) 2 | 3 | Implementation of non-trivial new features should typically be started off with the creation of an RFC (Request for Comments). 4 | 5 | 6 | ## Roadmaps 7 | 8 | Writeups of directions in major areas of interest 9 | 10 | | Roadmap | Description | 11 | | --- | --- | 12 | | N/A | TBD | 13 | 14 | 15 | ## v1.0 RFCs 16 | 17 | ocular 1.0 will support static page generation based on gatsby: 18 | 19 | | RFC | Author | Status | Description | 20 | | --- | --- | --- | --- | 21 | | [**gatsby-rfc.md) | @jckr/@ibgreen | **Draft** | Port ocular to use `gatsby` and support static content generation. | 22 | 23 | -------------------------------------------------------------------------------- /dev-docs/RFCs/v1.0/gatsby-rfc.md: -------------------------------------------------------------------------------- 1 | # RCF: Rebuild ocular on top of gatsby 2 | 3 | Author: @jckr / @ibgreen 4 | Date: Jan 2019 5 | Status: Draft 6 | 7 | 8 | ## Requirements: 9 | 10 | * Treat documentation as code 11 | * Build from checked-in markdown 12 | * Handle examples 13 | * Build pages for examples (React and pure-js) 14 | * Inject examples from checked-in code. 15 | 16 | 17 | ## Static Website Generators 18 | 19 | Gatsby - Written in React (Note: not a documentation generator for React) - A downside is extensive use of complicated JS ecosystem. Requires a high bar to learn, but overlaps with the front-end skills used by React developers. 20 | 21 | Some strong alternatives 22 | - Jekyll, written in Ruby. 23 | - Hugo, is written in Go and uses Go's template libraries. 24 | 25 | Some articles 26 | - [Quick Thoughts on Gatsby JS vs. Jekyll](https://medium.com/@ajkueterman/quick-thoughts-on-gatsby-js-vs-jekyll-c13c1337c24a) 27 | - [Gatsby vs Hugo article](https://medium.freecodecamp.org/gatsby-vs-hugo-a-detailed-comparison-e78d94f640fc) 28 | - [Gatsby vs Jekyll vs Hugo forum](https://www.reddit.com/r/FreeCodeCamp/comments/923js6/jekyll_vs_hugo_vs_gatsby/) 29 | 30 | 31 | ## Markdown Support 32 | 33 | Markdown support is very strong, handled through the remark based plugin which itself has an entire system of sub-plugins for code syntax formatting, image handling, etc. Also a number of styling sheets are available. 34 | 35 | The main effort is deciding how to load all the markdown into gatsby, how to query it from the resulting graphql tables, and then generating table of contents, and styling the markdown. 36 | 37 | 38 | ## Code Injection Support 39 | 40 | ### Use Cases 41 | 42 | * Examples need to be browsable from their own table of contents - Just publish examples as separate pages and use iframes? 43 | * We want to be able to inject a code sample on a page 44 | 45 | 46 | ###Alternatives 47 | 48 | #### repl (code sandbox) links 49 | 50 | The gasby remark plugin [gatsby-remark-code-repls](https://www.gatsbyjs.org/packages/gatsby-remark-code-repls/) is an interesting of option for "REPL-type environments" (like codepen). This can POST example code from the repo to the codepen using the "Codepen Prefill API". 51 | * See [React docs](https://reactjs.org/docs/rendering-elements.html) for example usage. 52 | 53 | * Currently examples are not inline, the plugin generates links that open the code in the repl sandbox 54 | 55 | COMMENT: Adding this feature is obviously extremely nice for any complete code snippets, but does not solve the example code injection problem as such 56 | 57 | 58 | #### [gatsby-remark-responsive-iframe](https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby-remark-responsive-iframe) 59 | 60 | Another gatsby remark plugin, wraps iframes or objects (e.g. embedded YouTube videos) within markdown files in a responsive elastic container with a fixed aspect ratio. This ensures that the iframe or object will scale proportionally and to the full width of its container. 61 | -------------------------------------------------------------------------------- /docs/BASEURL: -------------------------------------------------------------------------------- 1 | https://uber-web.github.io/ocular -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # Welcome 2 | 3 | ocular is a set of tools to help build and publish open source frameworks. It contains: 4 | - a `dev-tools` module that installs and provides base configurations for tools like webpack, babel, lerna, eslint prettier etc. 5 | - a `gatsby-theme-ocular` module that contains a markdown to HTML converter to make it easy to build websites. 6 | ## About ocular-dev-tools 7 | 8 | ocular-dev-tools installs a set of configurable development scripts to handle build, test and publish tasks for JavaScript framework repositories. 9 | 10 | While highly configurable ocular-dev-tools is very opinionated in choice of tooling etc, and mainly targets vis.gl frameworks, like deck.gl, luma.gl etc. 11 | 12 | ## About gatsby-theme-ocular 13 | 14 | The vis.gl team needed a system to build documentation websites with the least amount of friction. Our first use case has been the websites for the various visualization projects such as [deck.gl](https://deck.gl) [luma.gl](https://luma.gl) or [loaders.gl](https://loaders.gl). 15 | 16 | We wanted: 17 | - to organize documentation files with a table of contents, navigation and search; 18 | - to have interactive examples; 19 | - to have some control on formatting; 20 | - to generate websites discoverable by search engines; 21 | - to make it easy to publish these websites, especially on github pages; 22 | - to make this experience possible without writing a line of code; 23 | - to provide sensible defaults in terms of navigation and styling; 24 | - but to allow advanced users to overwrite and customize anything they want. 25 | 26 | Happy documenting! 27 | 28 | To find out more, go to [get started](get-started.md) 29 | 30 | -------------------------------------------------------------------------------- /docs/table-of-contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "table-of-contents", 3 | "chapters": [ 4 | { 5 | "title": "Overview", 6 | "entries": [ 7 | { 8 | "entry": "docs" 9 | } 10 | ] 11 | }, 12 | { 13 | "title": "ocular-dev-tools", 14 | "chapters": [ 15 | { 16 | "title": "Overview", 17 | "entries": [ 18 | { 19 | "entry": "modules/dev-tools/docs/" 20 | }, 21 | { 22 | "entry": "modules/dev-tools/docs/whats-new" 23 | }, 24 | { 25 | "entry": "modules/dev-tools/docs/upgrade-guide" 26 | }, 27 | { 28 | "entry": "modules/dev-tools/docs/faq" 29 | } 30 | ] 31 | }, 32 | { 33 | "title": "Configuration Guide", 34 | "entries": [ 35 | { 36 | "entry": "modules/dev-tools/docs/" 37 | }, 38 | { 39 | "entry": "modules/dev-tools/docs/developer-guide/command-line-interface" 40 | }, 41 | { 42 | "entry": "modules/dev-tools/docs/developer-guide/configuring-tests" 43 | }, 44 | { 45 | "entry": "modules/dev-tools/docs/developer-guide/aliases" 46 | } 47 | ] 48 | }, 49 | { 50 | "title": "Command Line Reference", 51 | "entries": [ 52 | { 53 | "entry": "modules/dev-tools/docs/cli/ocular-bootstrap" 54 | }, 55 | { 56 | "entry": "modules/dev-tools/docs/cli/ocular-build" 57 | }, 58 | { 59 | "entry": "modules/dev-tools/docs/cli/ocular-clean" 60 | }, 61 | { 62 | "entry": "modules/dev-tools/docs/cli/ocular-lint" 63 | }, 64 | { 65 | "entry": "modules/dev-tools/docs/cli/ocular-metrics" 66 | }, 67 | { 68 | "entry": "modules/dev-tools/docs/cli/ocular-publish" 69 | }, 70 | { 71 | "entry": "modules/dev-tools/docs/cli/ocular-test" 72 | }, 73 | { 74 | "entry": "modules/dev-tools/docs/cli/ocular-bump" 75 | } 76 | ] 77 | }, 78 | { 79 | "title": "API Reference", 80 | "entries": [ 81 | { 82 | "entry": "modules/dev-tools/docs/api-reference/get-babel-config" 83 | }, 84 | { 85 | "entry": "modules/dev-tools/docs/api-reference/get-eslint-config" 86 | }, 87 | { 88 | "entry": "modules/dev-tools/docs/api-reference/get-prettier-config" 89 | }, 90 | { 91 | "entry": "modules/dev-tools/docs/api-reference/get-webpack-config" 92 | } 93 | ] 94 | } 95 | ] 96 | }, 97 | { 98 | "title": "gatsby-theme-ocular", 99 | "chapters": [ 100 | { 101 | "title": "Overview", 102 | "entries": [ 103 | { 104 | "entry": "modules/gatsby-theme-ocular/docs" 105 | }, 106 | { 107 | "entry": "modules/gatsby-theme-ocular/docs/get-started" 108 | }, 109 | { 110 | "entry": "modules/gatsby-theme-ocular/docs/whats-new" 111 | }, 112 | { 113 | "entry": "modules/gatsby-theme-ocular/docs/upgrade-guide" 114 | } 115 | ] 116 | }, 117 | { 118 | "title": "Creating content", 119 | "entries": [ 120 | { 121 | "entry": "modules/gatsby-theme-ocular/docs" 122 | }, 123 | { 124 | "entry": "modules/gatsby-theme-ocular/docs/get-started" 125 | }, 126 | { 127 | "entry": "modules/gatsby-theme-ocular/docs/whats-new" 128 | }, 129 | { 130 | "entry": "modules/gatsby-theme-ocular/docs/upgrade-guide" 131 | } 132 | ] 133 | }, 134 | { 135 | "title": "Creating content", 136 | "entries": [ 137 | { 138 | "entry": "modules/gatsby-theme-ocular/docs/creating-content/writing-documentation" 139 | }, 140 | { 141 | "entry": "modules/gatsby-theme-ocular/docs/creating-content/interactive-examples" 142 | } 143 | ] 144 | }, 145 | { 146 | "title": "Developer Guide", 147 | "entries": [ 148 | { 149 | "entry": "modules/gatsby-theme-ocular/docs/developer-guide/configuring" 150 | }, 151 | { 152 | "entry": "modules/gatsby-theme-ocular/docs/developer-guide/deploying" 153 | }, 154 | { 155 | "entry": "modules/gatsby-theme-ocular/docs/developer-guide/debugging" 156 | } 157 | ] 158 | }, 159 | { 160 | "title": "API Reference", 161 | "entries": [ 162 | { 163 | "entry": "modules/gatsby-theme-ocular/docs/api-reference/options" 164 | }, 165 | { 166 | "entry": "modules/gatsby-theme-ocular/docs/api-reference/generated-pages" 167 | } 168 | ] 169 | } 170 | ] 171 | } 172 | ] 173 | } 174 | -------------------------------------------------------------------------------- /docs/wip/gatsby-theme-ocular/README.md: -------------------------------------------------------------------------------- 1 | # Overview 2 | 3 | Ocular is a tool primarily designed for building documentation websites for github-based javascript frameworks, built using the gatsbyjs documentation generation system. 4 | 5 | Using ocular in your framework requires: 6 | * a directory with github markdown 7 | * examples... 8 | 9 | 10 | ## Quick Setup 11 | 12 | If you already have markdown documentation written for your framework, setting up an initial ocular based page is very quick: 13 | 14 | * Create a `website` folder in your framework repository's root folder. 15 | * Create a package.json and install `ocular` in the website folder. 16 | * Create the file `website/gatsby-config.js`, copied from ... 17 | * Create the file `website/gatsby-node.js`, copied from ... 18 | * Create the file `website/site-config.js`, copied from and modified to fit your site. 19 | * Create a `table-of-contents.json` at the root of your markdown documentation folder. 20 | 21 | 22 | ## Deep Configuration 23 | 24 | Since your website contains the gatsbyjs entry point files (`gatsby-config.js` and `gatsby-node.js`) it is possible to take full control and override selected parts of ocular's documenation generation system. 25 | 26 | The ocular package exports most internal components used by ocular so that you can reuse them in building customized functionality. 27 | 28 | 29 | ## Functions 30 | 31 | ### getGatsbyConfig(options : Object) : Object 32 | 33 | This function takes your site configuration object and builds a complete gatsby configuration object, and populates it with a number of preinstalled plugins. This object is intended to be passed to gatsby as the exported value from your `website/gatsby-config.js` file. 34 | 35 | `getGatsbyConfig` is intended to be called in your `website/gatsby-config.js` file as follows: 36 | 37 | ``` 38 | require('reify'); // Enables ES6 "import" in imported files 39 | 40 | const {setSiteConfig, getGatsbyConfig} = require('ocular'); 41 | 42 | const config = require('./ocular-config'); 43 | 44 | setSiteConfig(config); 45 | 46 | module.exports = getGatsbyConfig(config); 47 | ``` 48 | 49 | NOTE: You can forward the returned object directly to gatsby, or you can modify it first, e.g. to delete or add plugins before passing it on to gatsby. Consult [gatsby docs](https://www.gatsbyjs.org/) for more information on `gatsby-config.js` options. 50 | 51 | 52 | ### getGatsbyNodeCallbacks() : Object 53 | 54 | Forward these callbacks to gatsby in your `website/gatsby-node.js` file to set up default ocular configuration. 55 | 56 | ``` 57 | require('reify'); // Enables ES6 "import" in imported files 58 | const {getGatsbyNodeCallbacks} = require('ocular'); 59 | 60 | module.exports = getGatsbyNodeCallbacks(); 61 | ``` 62 | 63 | NOTE: It is possible to override the ocular-provided callbacks and thus take full control of any aspect of gatsby's document generation process. Consult [gatsby docs](https://www.gatsbyjs.org/) for more information on `gatsby-node.js` callbacks. 64 | 65 | ``` 66 | require('reify'); // Enables ES6 "import" in imported files 67 | const {getGatsbyNodeCallbacks} = require('ocular'); 68 | 69 | module.exports = getGatsbyNodeCallbacks(); 70 | module.exports.onCreateNode = ({ node, actions, getNode }) => { 71 | // Do other things 72 | ... 73 | /// Call ocular default handling (or not) 74 | getGatsbyNodeCallbacks.onCreateNode({ node, actions, getNode }); 75 | }; 76 | ``` 77 | 78 | 79 | ## Components 80 | 81 | ocular provides a number of common React components that can be used to create custom pages. 82 | 83 | 84 | ### Layouts 85 | 86 | Layout components are components that remain static between pages 87 | 88 | 89 | #### Header 90 | 91 | 92 | #### Footer 93 | 94 | 95 | #### Table of Contents 96 | 97 | 98 | ### Common Components 99 | 100 | 101 | #### SEO 102 | 103 | Search engine optimization helper 104 | -------------------------------------------------------------------------------- /docs/wip/gatsby-theme-ocular/get-started.md: -------------------------------------------------------------------------------- 1 | # Quick start 2 | 3 | ## Installing Ocular 4 | 5 | From the project you want to create a website for, create a new folder: 6 | 7 | ``` 8 | mkdir website 9 | ``` 10 | 11 | Initialize that folder as a new project with its own package.json. 12 | 13 | From now on, we'll call that folder you've just created the Ocular folder. 14 | 15 | ``` 16 | npm init -y 17 | ``` 18 | 19 | then install Ocular as a devDependency. 20 | 21 | ``` 22 | yarn add -D gatsby-theme-ocular 23 | ``` 24 | or 25 | ``` 26 | npm install gatsby-theme-ocular --save-dev 27 | ``` 28 | 29 | ## Creating and running your Ocular website 30 | 31 | Now, start the Ocular project: 32 | 33 | ``` 34 | ocular init 35 | ``` 36 | 37 | This will prompt you with a few questions, and create a number of files and folders in the Ocular folder. 38 | The most important of these file is `gatsby-config.js` in the Ocular folder, which contains all the settings for your website. You can edit it later. 39 | 40 | Now install any remaining packages: 41 | ``` 42 | yarn 43 | ``` 44 | or 45 | ``` 46 | npm install 47 | ``` 48 | 49 | Your project will need a `table-of-contents.json` file in the same location you have your documentation files. You can create one manually but Ocular can also create one for you by typing: 50 | ``` 51 | yarn build-toc 52 | ``` 53 | or 54 | ``` 55 | npm run build-toc 56 | ``` 57 | 58 | At this stage, you can see your website by typing: 59 | 60 | ``` 61 | yarn start 62 | ``` 63 | or 64 | ``` 65 | npm run start 66 | ``` 67 | 68 | ## Writing content 69 | 70 | You're going to need documentation files for your documentation website. 71 | Your `gatsby-config.js` file will contain the location of these files. Read [Writing documentation](./creating-content/writing-documentation) to know all about that part. 72 | And your documentation files will be available on your website! 73 | 74 | ## Publishing your website 75 | 76 | That's all you need if you just want to have your website running on your machine. But if you want to have your site running somewhere else, such as GitHub, that's not enough. 77 | 78 | From the ocular folder, type 79 | 80 | ``` 81 | yarn build 82 | ``` 83 | or 84 | ``` 85 | npm run build 86 | ``` 87 | And this will generate a static website in the folder `public` (a sub-folder of your Ocular folder) 88 | You can go to that folder and test your built website by typing 89 | ``` 90 | yarn serve 91 | ``` 92 | or 93 | ``` 94 | npm run serve 95 | ``` 96 | 97 | You can now safely upload the contents of this folder on a web server. If you want to deploy this website to GitHub Pages, and your project is already hosted on github, you can instead type: 98 | 99 | ``` 100 | yarn deploy 101 | ``` 102 | or 103 | ``` 104 | npm run deploy 105 | ``` 106 | -------------------------------------------------------------------------------- /docs/wip/gatsby-theme-ocular/upgrade-guide.md: -------------------------------------------------------------------------------- 1 | # Upgrade Guide 2 | 3 | 4 | ## gatsby-theme-ocular 5 | 6 | ### Upgrading from v1.1 to v1.2 7 | 8 | Breaking changes: 9 | - INDEX_PAGE_URL 10 | 11 | ### Upgrading from ocular-gatsby to gatsby-theme-ocular 12 | 13 | Your website needs to update its `gatsby-config.js` and `gatsby-node.js` in the root, and unless you have added additional code, you can remove your `gatsby-browser.js` and `gatsby-ssr.js` as the default implementations can now be supplied by `gatsby-theme-ocular`. 14 | 15 | `gatsby-config.js`: 16 | ```js 17 | const ocularConfig = require('./ocular-config'); 18 | 19 | module.exports = { 20 | plugins: [{resolve: `gatsby-theme-ocular`, options: ocularConfig}], 21 | }; 22 | ``` 23 | 24 | `gatsby-node.js`: 25 | ```js 26 | const {setOcularConfig} = require('gatsby-theme-ocular'); 27 | 28 | const ocularConfig = require('./ocular-config'); 29 | setOcularConfig(ocularConfig); 30 | ``` -------------------------------------------------------------------------------- /examples/dev-tools/.eslintrc.js: -------------------------------------------------------------------------------- 1 | const {getESLintConfig} = require('ocular-dev-tools'); 2 | 3 | const config = getESLintConfig({react: '16.8.2'}); 4 | 5 | // Make any changes to default config here 6 | 7 | // Uncomment to log the eslint config 8 | // console.debug(config); 9 | 10 | module.exports = config; 11 | -------------------------------------------------------------------------------- /examples/dev-tools/.prettierrc.js: -------------------------------------------------------------------------------- 1 | const {getPrettierConfig} = require('ocular-dev-tools'); 2 | 3 | const config = getPrettierConfig({react: '16.8.2'}); 4 | 5 | // Make any changes to default config here 6 | 7 | // Uncomment to log the eslint config 8 | // console.debug(config); 9 | 10 | module.exports = config; 11 | -------------------------------------------------------------------------------- /examples/dev-tools/babel.config.js: -------------------------------------------------------------------------------- 1 | const {getBabelConfig} = require('ocular-dev-tools'); 2 | 3 | module.exports = (api) => { 4 | const config = getBabelConfig(api, {react: true}); 5 | 6 | // Make any changes to default config here 7 | 8 | // Uncomment to log the config 9 | // console.debug(config); 10 | 11 | return config; 12 | }; 13 | -------------------------------------------------------------------------------- /examples/dev-tools/dist/es5/app.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard"); 4 | 5 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); 6 | 7 | Object.defineProperty(exports, "__esModule", { 8 | value: true 9 | }); 10 | exports.renderToDOM = renderToDOM; 11 | exports.default = void 0; 12 | 13 | var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); 14 | 15 | var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); 16 | 17 | var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")); 18 | 19 | var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")); 20 | 21 | var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")); 22 | 23 | var _react = _interopRequireWildcard(require("react")); 24 | 25 | var _reactDom = require("react-dom"); 26 | 27 | function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; } 28 | 29 | function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } 30 | 31 | var App = function (_PureComponent) { 32 | (0, _inherits2.default)(App, _PureComponent); 33 | 34 | var _super = _createSuper(App); 35 | 36 | function App(props) { 37 | var _this; 38 | 39 | (0, _classCallCheck2.default)(this, App); 40 | _this = _super.call(this, props); 41 | _this.state = {}; 42 | return _this; 43 | } 44 | 45 | (0, _createClass2.default)(App, [{ 46 | key: "render", 47 | value: function render() { 48 | return _react.default.createElement("div", { 49 | style: { 50 | color: 'red' 51 | } 52 | }, _react.default.createElement("p", null, "This is a minimal React example"), _react.default.createElement("p", null, "Line..."), _react.default.createElement("p", null, "Line..."), _react.default.createElement("p", null, "Line..."), _react.default.createElement("p", null, "Line...")); 53 | } 54 | }]); 55 | return App; 56 | }(_react.PureComponent); 57 | 58 | exports.default = App; 59 | 60 | function renderToDOM(container) { 61 | (0, _reactDom.render)(_react.default.createElement(App, null), container); 62 | } 63 | //# sourceMappingURL=app.js.map -------------------------------------------------------------------------------- /examples/dev-tools/dist/es5/app.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../../src/app.js"],"names":["App","props","state","color","PureComponent","renderToDOM","container"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;IAEqBA,G;;;;;AACnB,eAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AACA,UAAKC,KAAL,GAAa,EAAb;AAFiB;AAGlB;;;;WAED,kBAAS;AACP,aACE;AAAK,QAAA,KAAK,EAAE;AAACC,UAAAA,KAAK,EAAE;AAAR;AAAZ,SACE,0EADF,EAEE,kDAFF,EAGE,kDAHF,EAIE,kDAJF,EAKE,kDALF,CADF;AASD;;;EAhB8BC,oB;;;;AAmB1B,SAASC,WAAT,CAAqBC,SAArB,EAAgC;AACrC,wBAAO,6BAAC,GAAD,OAAP,EAAgBA,SAAhB;AACD","sourcesContent":["import React, {PureComponent} from 'react';\nimport {render} from 'react-dom';\n\nexport default class App extends PureComponent {\n constructor(props) {\n super(props);\n this.state = {};\n }\n\n render() {\n return (\n
This is a minimal React example
\nLine...
\nLine...
\nLine...
\nLine...
\nThis is a minimal React example
\nLine...
\nLine...
\nLine...
\nLine...
\n