# Contributing

## I would like to contribute code - how do I do this?

Fork the repository, make your change and submit a pull request.

- The OHIF Viewer consists of code from three different repositories. Make sure
  your change is modifying the appropriate one:
  - `ohif-core`: Business Logic
  - `react-viewerbase`: Reusable React Component Library
  - `Viewers`: The glue, PWA, and primary extension point
- At a minimum, you may want to read the following documentation:
  - [Essentials: Getting Started](./essentials/getting-started.md)
  - [Advanced: Architecture](./advanced/architecture.md)

### When changes impact multiple repositories

This is a particularly tricky scenario. We don't want to publish code in one
repository, just so we can test and complete the other half of its requirements
in another. Thankfully, there are a couple of ways you can test unpublished
dependent changes locally before publishing:

- [Use `yarn link`](https://yarnpkg.com/en/docs/cli/link)

For example if you are working on `ohif-core` and would like to use your local
version to debug a problem in `Viewers`, simply run yarn link inside of the
`ohif-core` project.

- If you're experiencing issues with `yarn link`,
  [try `yalc`](https://github.com/whitecolor/yalc)

Yalc provides an improved workflow as we add more and more dependent packages
that are "in-progress". This comes into play as we begin working on extensions
and their dependencies.

```js
// Install yalc for the first time
yarn global add yalc

// EXAMPLE: using an in-development version of ohif-core w/ Viewers locally
// 1. Navigate to ohif-core's project root
yarn install
yalc publish

// 2. Run the following after each change to ohif-core
yarn build
yalc push .

// 3. Use the local package in our Viewers project. Navigate to the Viewers
//    Project root.
yarn install
yalc add ohif-core
yarn run dev
```

## Any guidance on submitting changes?

While we do appreciate code contributions, triaging and integrating contributed
code changes can be very time consuming. Please consider the following tips when
working on your pull requests:

- Functionality is appropriate for the repository. Consider creating a GitHub
  issue to discuss your suggested changes.
- The scope of the pull request is not too large. Please consider separate pull
  requests for each feature as big pull requests are very time consuming to
  understand.

We will provide feedback on your pull requests as soon as possible. Following
the tips above will help ensure your changes are reviewed.

## Testing contribution pull requests

OHIF uses [netlify](netlify.com) so that pull requests are autogenerated and
available for testing.

For example, [this url][example-url] allows you to test [pull request 237, the
request that created this FAQ entry,][pr-237] using data pulled from Amazon S3.

Replacing the number 237 in the link below with your pull request number should
let you test it as well and you can use this link for discussions on github
without requiring reviewers to download and build your branch.

```bash
https://deploy-preview-237--ohif.netlify.com/viewer/?url=https://s3.eu-central-1.amazonaws.com/ohif-viewer/sampleDICOM.json
```

If you have made a documentation change, a link like this will let you preview
the gitbook generated by the pull request:

```bash
https://deploy-preview-237--ohif.netlify.com/contributing.html
```

<!--
  Links
  -->

<!-- prettier-ignore-start -->

[example-url]: https://deploy-preview-237--ohif.netlify.com/viewer/?url=https://s3.eu-central-1.amazonaws.com/ohif-viewer/sampleDICOM.json
[pr-237]: https://github.com/OHIF/Viewers/pull/237

<!-- prettier-ignore-end -->
