Skip to content

Commit

Permalink
Setup documentation and docusaurus (#16)
Browse files Browse the repository at this point in the history
* docs: add readme and contributing files

Signed-off-by: andrei-zgirvaci <[email protected]>

* chore: setup docusaurus

Signed-off-by: andrei-zgirvaci <[email protected]>

* ci: setup cd

Signed-off-by: andrei-zgirvaci <[email protected]>

---------

Signed-off-by: andrei-zgirvaci <[email protected]>
  • Loading branch information
andrei-zgirvaci authored Apr 9, 2024
1 parent cded0ca commit 0b2a1f4
Show file tree
Hide file tree
Showing 40 changed files with 1,485 additions and 1 deletion.
47 changes: 46 additions & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Distribute Sample App to App Center
name: Distribute Sample App to App Center & Build Docs

on:
push:
Expand Down Expand Up @@ -54,3 +54,48 @@ jobs:
notifyTesters: true
debug: true
gitReleaseNotes: true

build-docs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Build docs
run: |
cd docs
bun run build
- name: Upload Build Artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/build

deploy-docs:
needs: build-docs

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
111 changes: 111 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Development workflow

This project is a monorepo managed using [Bun workspaces](https://bun.sh/docs/install/workspaces). It contains the following packages:

- An example app in the `apps/sample-app/` directory.
- The core library in the `packages/react-native-auth-core/` directory.
- Provider packages in the `packages/react-native-auth-*/` directories.

To get started with the project, run the following command in the root directory to install the required dependencies for each package:

```bash
bun install
```

The [example app](https://github.com/openmobilehub/react-native-omh-auth/tree/main/apps/sample-app/) demonstrates usage of the library. You need to run it to test any changes you make.

It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.

To edit the Java or Kotlin files, open `apps/sample-app/android` in Android studio and find the source files at `omh_react-native-auth-*` under `Android`.

You can use various commands from the root directory to work with the project.

To start the packager:

```bash
cd apps/sample-app && bun start
```

To run the example app on Android:

```bash
cd apps/sample-app && bun android
```

To run the example app on iOS:

```bash
cd apps/sample-app && bun ios
```

Make sure your code passes TypeScript and ESLint. Run the following to verify:

```bash
bun lint
bun typecheck
```

To fix formatting errors, run the following:

```bash
bun lint --fix
```

Remember to add tests for your change if possible. Run the unit tests by:

```bash
bun test
```

## Commit message convention

We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:

- `fix`: bug fixes, e.g. fix crash due to deprecated method.
- `feat`: new features, e.g. add new method to the module.
- `refactor`: code refactor, e.g. migrate from class components to hooks.
- `docs`: changes into documentation, e.g. add usage example for the module..
- `test`: adding or updating tests, e.g. add integration tests using detox.
- `chore`: tooling changes, e.g. change CI config.

Our pre-commit hooks verify that your commit message matches this format when committing.

## Linting and tests

We use [TypeScript](https://www.typescriptlang.org) for type checking, [ESLint](https://eslint.org) with [Prettier](https://prettier.io) for linting and formatting the code, and [Jest](https://jestjs.io) for testing.

Our pre-commit hooks verify that the linter and tests pass when committing.

## Publishing to npm

We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.

To publish new versions, run the following:

```bash
bun release
```

## Writing documentation

Documentation is located under [`/docs/`](https://github.com/openmobilehub/react-native-omh-auth/tree/main/docs). We use [Docusaurus](https://docusaurus.io) to generate the documentation website and [docusaurus-plugin-typedoc](https://www.npmjs.com/package/docusaurus-plugin-typedoc) to generate API documentation from TypeScript docstrings. The API documentation is built automatically with Github Actions and published on GitHub Pages upon merging to the `main` branch with [this workflow file](https://github.com/openmobilehub/react-native-omh-auth/tree/main/.github/workflows/cd.yml).

Remember to document your code according to [JSDoc reference](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html) and to write proper Markdown documentation manually when needed in the `/docs/docs/` directory.

You can view information about the documentation and its scripts in the [README](https://github.com/openmobilehub/react-native-omh-auth/tree/main/docs/README.md). To simply run documentation locally, you can run:

```bash
cd docs && bun start
```

## Sending a pull request

> **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
When you're sending a pull request:

- Prefer small pull requests focused on one change.
- Verify that linters and tests are passing.
- Review the documentation to make sure it looks good.
- Follow the pull request template when opening a pull request.
- For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# React Native OMH Auth

React Native OMH Auth Core package

## Installation

```bash
npm install --save @omh/react-native-auth-core
npm install --save @omh/react-native-auth-plugin-...
```

## Usage

```js
import {GoogleAuth} from '@omh/react-native-auth-google';

await GoogleAuth.initialize(['openid', 'email', 'profile']);

await googleAuthProvider.signIn();
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
Binary file modified bun.lockb
Binary file not shown.
20 changes: 20 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
43 changes: 43 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Website

This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.

API docs are generated automatically using [docusaurus-plugin-typedoc](https://www.npmjs.com/package/docusaurus-plugin-typedoc). Typedoc entrypoints are loaded from [`entrypoints.json`](./entrypoints.json) via [`docusaurus.config.ts`](docusaurus.config.ts) and corresponding Markdown outputs are emitted to [`/docs/docs/api`](./docs/api). The [`/docs/docs/contributing.mdx`](/docs/docs/contributing.mdx) file is a wrapper that imports & renders root project's [`CONTRIBUTING.md`](/CONTRIBUTING.md) file to reduce redundancy. This `contributing.mdx` file - apart from functioning standalone - is processed by `typedoc-plugin-replace-text` to replace `CONTRIBUTING.md`'s relative links with Docusaurus docs files tree links.

### Installation

```
$ yarn
```

### Local Development

```
$ yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

Using SSH:

```
$ USE_SSH=true yarn deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
3 changes: 3 additions & 0 deletions docs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
1 change: 1 addition & 0 deletions docs/docs/api/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
label: "API"
2 changes: 2 additions & 0 deletions docs/docs/api/classes/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
label: "Classes"
position: 3
Loading

0 comments on commit 0b2a1f4

Please sign in to comment.