|
| 1 | +# Contributing to Swift-DocC-Render |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +### Welcome |
| 6 | + |
| 7 | +Thank you for considering contributing to Swift-DocC-Render. |
| 8 | + |
| 9 | +Please know that everyone is welcome to contribute to Swift-DocC-Render. |
| 10 | +Contributing doesn’t just mean submitting pull requests—there |
| 11 | +are many different ways for you to get involved, |
| 12 | +including answering questions on the |
| 13 | +[Swift Forums](https://forums.swift.org/c/development/swift-docc), |
| 14 | +reporting or screening bugs, and writing documentation. |
| 15 | + |
| 16 | +No matter how you want to get involved, |
| 17 | +we ask that you first learn what’s expected of anyone who participates in |
| 18 | +the project by reading the [Swift Community Guidelines](https://swift.org/community/) |
| 19 | +as well as our [Code of Conduct](/CODE_OF_CONDUCT.md). |
| 20 | + |
| 21 | +This document focuses on how to contribute code and documentation to |
| 22 | +this repository. |
| 23 | + |
| 24 | +### Legal |
| 25 | + |
| 26 | +By submitting a pull request, you represent that you have the right to license your |
| 27 | +contribution to Apple and the community, and agree by submitting the patch that your |
| 28 | +contributions are licensed under the Apache 2.0 license (see [`LICENSE.txt`](/LICENSE.txt)). |
| 29 | + |
| 30 | +## Contributions Overview |
| 31 | + |
| 32 | +Swift-DocC-Render is an open source project and we encourage contributions |
| 33 | +from the community. |
| 34 | + |
| 35 | +### Contributing Code and Documentation |
| 36 | + |
| 37 | +Before contributing code or documentation to Swift-DocC-Render |
| 38 | +we encourage you to first create an issue on [Swift JIRA](https://bugs.swift.org/) |
| 39 | +for a bug report or feature request. |
| 40 | +This will allow us to provide feedback on the proposed change. |
| 41 | +However, this is not a requirement. If your contribution is small in scope, |
| 42 | +feel free to open a PR without first creating an issue. |
| 43 | + |
| 44 | +All changes to Swift-DocC-Render source must go through the PR review process before |
| 45 | +being merged into the `main` branch. |
| 46 | +See the [Code Contribution Guidelines](#code-contribution-guidelines) below for |
| 47 | +more details. |
| 48 | + |
| 49 | +## Build and Run Swift-DocC-Render |
| 50 | + |
| 51 | +### Run Steps |
| 52 | + |
| 53 | +> Note: requires [Node.js](https://nodejs.org/en/download/) v14 |
| 54 | +> and [npm](https://www.npmjs.com/package/npm) v6.14 |
| 55 | +
|
| 56 | +1. Checkout this repository using: |
| 57 | + |
| 58 | + ```shell |
| 59 | + git clone [email protected]:apple/swift-docc-render.git |
| 60 | + ``` |
| 61 | + |
| 62 | +2. Navigate to the root of your cloned repository with: |
| 63 | + |
| 64 | + ```shell |
| 65 | + cd swift-docc-render |
| 66 | + ``` |
| 67 | + |
| 68 | +3. Install dependencies: |
| 69 | + |
| 70 | + ```shell |
| 71 | + npm install |
| 72 | + ``` |
| 73 | + |
| 74 | +4. Run a local server with hot reload at [localhost:8080](http://localhost:8080/) |
| 75 | + |
| 76 | + You may want to set an http endpoint as a proxy to handle data requests while developing locally. |
| 77 | + |
| 78 | + ```shell |
| 79 | + VUE_APP_DEV_SERVER_PROXY=https://localhost:8000 npm run serve |
| 80 | + ``` |
| 81 | + |
| 82 | + As an alternative you can just create a `.env.development.local` file on the root of the project to add the `VUE_APP_DEV_SERVER_PROXY` env varible so you don't have to set it in the `npm run serve` script each time. |
| 83 | + |
| 84 | +### Build Steps |
| 85 | +
|
| 86 | +To build Swift-DocC-Render for deployment, run the command below. The output will be generated inside the `dist` folder: |
| 87 | +
|
| 88 | +```shell |
| 89 | +npm run build |
| 90 | +``` |
| 91 | +
|
| 92 | +## Testing Swift-DocC-Render using data from Swift-DocC |
| 93 | +
|
| 94 | +Follow [these steps](https://github.com/apple/swift-docc#using-docc-to-build-and-preview-documentation) to generate a documentation archive, set the path to your renderer and render locally your documentation using Swift-DocC-Render. |
| 95 | +
|
| 96 | +## Code Contribution Guidelines |
| 97 | +
|
| 98 | +### Overview |
| 99 | +
|
| 100 | +- Do your best to keep the git history easy to understand. |
| 101 | + |
| 102 | +- Use informative commit titles and descriptions. |
| 103 | + - Include a brief summary of changes as the first line. |
| 104 | + - Describe everything that was added, removed, or changed, and why. |
| 105 | +
|
| 106 | +- All changes must go through the pull request review process. |
| 107 | +
|
| 108 | +### Pull Request Preparedness Checklist |
| 109 | +
|
| 110 | +When you're ready to have your change reviewed, please make sure you've completed the following requirements: |
| 111 | +
|
| 112 | +- [x] Add Swift's license header to the new files. |
| 113 | + |
| 114 | +- [x] Add tests to cover any new functionality or to prevent regressions of a bug fix. |
| 115 | + |
| 116 | +- [x] Run the `npm run test` script and confirm that the unit test, lint and license header checks pass. |
| 117 | + |
| 118 | +- [x] Add source code documentation to all added coded that explains |
| 119 | + the new behavior. |
| 120 | + |
| 121 | +### Opening a Pull Request |
| 122 | + |
| 123 | +When opening a pull request, please make sure to fill out the pull request template |
| 124 | +and complete all tasks mentioned there. |
| 125 | + |
| 126 | +Your PR should mention the number of the [Swift JIRA](https://bugs.swift.org/) |
| 127 | +issue your work is addressing (SR-NNNNN). |
| 128 | + |
| 129 | +Most PRs should be against the `main` branch. If your change is intended |
| 130 | +for a specific release, you should also create a separate branch |
| 131 | +that cherry-picks your commit onto the associated release branch. |
| 132 | + |
| 133 | +### Code Review Process |
| 134 | + |
| 135 | +All PRs will need approval from someone on the core team |
| 136 | +(someone with write access to the repository) before being merged. |
| 137 | + |
| 138 | +## Testing and Linting |
| 139 | + |
| 140 | +Swift-DocC-Render is committed to maintaining a high level of code quality. |
| 141 | +Before opening a pull request, we ask that you: |
| 142 | + |
| 143 | +1. Run the full test suite and confirm that it passes. |
| 144 | + |
| 145 | +2. Write new tests to cover any changes you made. |
| 146 | + |
| 147 | +### Tests and linting |
| 148 | + |
| 149 | +Run the following script to: |
| 150 | +- Run unit tests with [Jest](https://jestjs.io/) |
| 151 | +- Find syntax errors with [ESLint](https://eslint.org/) |
| 152 | +- Check that all files have license headers |
| 153 | + |
| 154 | +```shell |
| 155 | +npm run test |
| 156 | +``` |
| 157 | + |
| 158 | +Run an individual unit test suite: |
| 159 | + |
| 160 | +```shell |
| 161 | +npm run test:unit tests/unit/path/to/spec.js |
| 162 | +``` |
| 163 | + |
| 164 | +Run unit tests and watch for changes: |
| 165 | + |
| 166 | +```shell |
| 167 | +npm run test:unit:watch |
| 168 | +``` |
| 169 | + |
| 170 | +To manually lint your code for style issues, you can run the [ESLint](https://eslint.org/) suite: |
| 171 | + |
| 172 | +```shell |
| 173 | +npm run lint |
| 174 | +``` |
| 175 | + |
| 176 | +If you want the linter to automatically fix the errors it finds, run: |
| 177 | + |
| 178 | +```shell |
| 179 | +npm run lint:fix |
| 180 | +``` |
| 181 | + |
| 182 | +## Your First Contribution |
| 183 | + |
| 184 | +Unsure of where to begin contributing to Swift-DocC-Render? You can start by looking at |
| 185 | +the bugs in the `Swift-DocC-Render` component with the `StarterBug` label on |
| 186 | +[Swift JIRA](https://bugs.swift.org/issues/?jql=project%20%3D%20SR%20AND%20status%20in%20(Open%2C%20Reopened)%20AND%20component%20%3D%20Swift-DocC-Render%20AND%20labels%20%3D%20StarterBug). |
| 187 | + |
| 188 | +Once you've found an issue to work on, |
| 189 | +follow the above instructions for [Building Swift-DocC-Render](#build-and-run-swift-docc-render). |
| 190 | +
|
| 191 | +<!-- Copyright (c) 2021 Apple Inc and the Swift Project authors. All Rights Reserved. --> |
0 commit comments