mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-11-29 09:01:25 +01:00
4.4 KiB
4.4 KiB
How To Contribute
- Most work happens in sub modules. These are found in the
packagesdirectory prefixed with "digitransit-component-". - If you would like to propose a new feature, open an issue.
- Always include tests. We use mocha and chai.
- digitransit-component modules are small, containing a single exported function.
- Avoid large dependencies at all costs.
- The
README.mdfiles inpackages/digitransit-component-<module>are automatically generated from the JSDocs of theindex.js. Please modify the JSDocs instead of modifying theREADME.mdfiles directly. Then update/create theREADME.mdexecuting./scripts/generate-readmesor runningyarn run docsfrom the root Dir directory. - Finally run
yarn run testfrom the project root folder to run all the tests required for deploying the project.
Code Style
To ensure code style, at the digitransit-ui root level run
$ yarn run lint
- Follow the AirBNB JavaScript code style.
Structure of a digitransit-component module
digitransit-component-<MODULE NAME>
│ index.generated
│ index.js
│ LICENSE-AGPL.txt
│ LICENSE-EUPL.txt
│ package.json
│ README.md
│ test.generated
│ test.js
To get started with a new module navigate to the root directory and run
$ yarn run digitransit-component-new-module <MODULE NAME>
it will create a new folder inside packages with a simple boilerplate for your module.
index.js- This file contains, in order, the various modules you need to import, the JSDocs documentation, and, finally, the single exported class that the module provides.test.js- This file includes your mocha and chai tests.test.generated- This file is generated fromtest.jsusing Babel.package.json- The node metadata container file. Modules imported inindex.jsshould be listed here underdependencies, and modules used intest.jsshould be listed underdevDependencies.npm installlooks to this file to install dependencies in./node_modules.README.md- This README is generated automatically by runningnpm run docsfrom the project root level. DO NOT edit this file.LICENCE- Like the README, this file should not be edited.
Compiling with Babel
To get component working it must be compiled with Babel. Babel is a toolchain that is mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments.
Navigate to the component's directory and run
$ yarn build:index && yarn build:test
it will create two files.
index.generated- This file has been generated fromindex.js.test.generated- This file has been generated fromtest.js.
Publishing
Publish inside a module::
$ yarn publish
Documentation
To update digitransit-component's Documentation (README.md) use the following yarn run docs:
- inside a module: will only generate the docs of that module.
- main folder: will generate docs for all modules.
Documentation - Examples
Only builds docs for @digitransit-component/foo
$ cd ./digitransit-component/packages/digitransit-component-foo
$ yarn run digitransit-component-docs
> @digitransit-component/foo@1.0.0 docs /Users/foobar/projects/digitransit-ui/digitransit-component/packages/digitransit-component
> node ../../scripts/generate-readmes
Building Docs: @digitransit-component/foo
Builds docs for all modules
$ cd ./digitransit-ui
$ yarn run digitransit-component-docs
> @1.0.0 docs /Users/foobar/projects/digitransit-ui/digitransit-component
> node ./scripts/generate-readmes
Building Docs: @digitransit-component/foo
Building Docs: @digitransit-component/goo
Building Docs: @digitransit-component/hoo
....