2023-07-11 20:31:52 +03:00
# Redoc Contributing Guide
2018-01-23 14:49:06 +03:00
2023-07-11 20:31:52 +03:00
Hi! We're really excited that you are interested in contributing to Redoc. Before submitting your contribution though, please make sure to take a moment and read through the following guidelines.
2018-01-23 14:49:06 +03:00
2023-07-11 20:31:52 +03:00
- [Redoc Contributing Guide ](#redoc-contributing-guide )
- [Issue Reporting Guidelines ](#issue-reporting-guidelines )
- [Pull Request Guidelines ](#pull-request-guidelines )
- [Development Setup ](#development-setup )
- [Commonly used NPM scripts ](#commonly-used-npm-scripts )
- [Project Structure ](#project-structure )
2018-01-23 14:49:06 +03:00
## Issue Reporting Guidelines
- Before filing a new issue, try to make sure your problem doesn’ t already exist.
- The best way to get your bug fixed is to provide a reduced test case.
## Pull Request Guidelines
Before submitting a pull request, please make sure the following is done:
2022-09-12 19:28:47 +03:00
1. Fork the repository and create your branch from main.
2020-03-17 12:06:03 +03:00
2. Run `npm install` in the repository root.
2018-01-23 14:49:06 +03:00
3. If you’ ve fixed a bug or added code that should be tested, add tests!
2020-03-17 12:06:03 +03:00
4. Ensure the test suite passes (`npm test`). Tip: `npm test -- --watch TestName` is helpful in development.
5. Format your code with prettier (`npm run prettier`).
2018-01-23 14:49:06 +03:00
## Development Setup
2023-07-11 20:31:52 +03:00
You need [Node.js ](http://nodejs.org ) at `v12.0.0+` .
2018-01-23 14:49:06 +03:00
After cloning the repo, run:
```bash
2020-03-17 12:06:03 +03:00
$ npm install # or npm
2018-01-23 14:49:06 +03:00
```
### Commonly used NPM scripts
``` bash
# dev-server, watch and auto reload playground
2020-03-17 12:06:03 +03:00
$ npm start
2018-01-23 14:49:06 +03:00
2019-12-10 09:13:37 +03:00
# start playground app in production environment
2020-03-17 12:06:03 +03:00
$ npm run start:prod
2018-01-23 14:49:06 +03:00
# runt tslint
2020-03-17 12:06:03 +03:00
$ npm run lint
2018-01-23 14:49:06 +03:00
# try autofix tslint issues
2020-03-17 12:06:03 +03:00
$ npm run lint -- --fix
2018-01-23 14:49:06 +03:00
# run unit tests
2020-03-17 12:06:03 +03:00
$ npm run unit
2018-01-23 14:49:06 +03:00
# run e2e tests
2020-03-17 12:06:03 +03:00
$ npm run e2e
2020-04-08 14:04:58 +03:00
# Make sure you have created bundle before running e2e test
# E.g. run `npm run bundle` and wait for the finishing process.
2018-01-23 14:49:06 +03:00
# open cypress UI to debug e2e test
2020-03-17 12:06:03 +03:00
$ npm run cy:open
2018-01-23 14:49:06 +03:00
2020-04-08 14:04:58 +03:00
# run the unit tests (includes linting and license checks)
2020-03-17 12:06:03 +03:00
$ npm test
2018-01-23 14:49:06 +03:00
# prepare bundles
2020-03-17 12:06:03 +03:00
$ npm run bundle
2018-01-23 14:49:06 +03:00
# format the code using prettier
2020-03-17 12:06:03 +03:00
$ npm run prettier
2018-01-23 14:49:06 +03:00
# auto-generate changelog
2020-03-17 12:06:03 +03:00
$ npm run changelog
2018-01-23 14:49:06 +03:00
```
There are some other scripts available in the `scripts` section of the `package.json` file.
## Project Structure
2018-01-29 14:09:38 +03:00
- **`benchmark`**: contains basic perf benchmark. Not fully ready yet
2018-01-23 14:49:06 +03:00
- **`demo`**: contains project demo with demo specs and HMR playground used in development
- `demo/playground` : HMR Playground used in development
- **`docs`**: contains extra docs (linked from README.md)
- **`e2e`**: contains e2e tests. The e2e tests are written and run with [Cypress ](https://www.cypress.io/ ).
- **`src`**: contains the source code. The codebase is written in Typescript. CSS styles are managed with [Styled components ](https://www.styled-components.com/ ). State is managed by [MobX ](https://github.com/mobxjs/mobx )
2019-12-10 09:13:37 +03:00
- **`src/common-elements`**: contains common Styled elements or components used in multiple places
2018-01-23 14:49:06 +03:00
- **`src/components`**: contains main visual components
2023-07-11 20:31:52 +03:00
- **`src/services`**: contains different services used by Redoc including MobX stores
2018-01-23 14:49:06 +03:00
- **`src/services/models`**: contains classes for OpenAPI entities (e.g. Response, Operations, etc)
- **`src/types`**: contains extra typescript typings including OpenAPI doc typings
- **`src/utils`**: utility functions
2019-10-12 12:24:03 +03:00
- **`src/styled-components.ts`**: - reexports styled-components with proper typescript annotations using theme
2018-12-06 16:17:57 +03:00
- **`src/theme.ts`**: - default theme (colors, fonts, etc) used by all the components