Skip to content

Commit

Permalink
docs: added static docs site
Browse files Browse the repository at this point in the history
  • Loading branch information
retr0h committed Jun 19, 2024
1 parent c9a39eb commit 6619bf4
Show file tree
Hide file tree
Showing 28 changed files with 33,490 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/docs-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Test Deploy to GitHub Pages

on:
pull_request:
branches:
- main

jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
cache-dependency-path: ./docs/yarn.lock
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Lint the website
run: task docs:fmt:check
- name: Test build website
run: task docs:build
49 changes: 49 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: Deploy to GitHub Pages

on:
push:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

permissions:
contents: write

jobs:
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
cache-dependency-path: ./docs/yarn.lock
- name: Install Task
uses: arduino/setup-task@v2
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build website
run: task docs:build

# Popular action to deploy to GitHub Pages:
# Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Build output to publish to the `gh-pages` branch:
publish_dir: ./docs/build
# The following lines assign commit authorship to the official
# GH-Actions bot for deploys to `gh-pages` branch:
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
# The GH actions bot is used by default if you didn't specify the two fields.
# You can swap them out with your own user credentials.
user_name: github-actions[bot]
user_email: 41898282+github-actions[bot]@users.noreply.github.com


12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,29 @@

# Git URL Parse

<img src="asset/logo.png" align="left" width="20%" height="20%" />

This project is a golang port of an old project of mine [git-url-parse][],
which was donated to [coala][], and partially inspired by [go-git-url][].

It's usefulness may be limited, but I have a [fascination][] with revisiting
old projects.

<br clear="left"/>

[git-url-parse]: https://github.com/coala/git-url-parse
[coala]: https://coala.io/#/home?lang=Python
[fascination]: https://retr0h.github.io/gilt/
[go-git-url]: https://github.com/kubescape/go-git-url/tree/master

## Documentation

[Installation][] | [Usage][] | [Documentation][]

[Installation]: https://retr0h.github.io/git-url-parse/installation
[Usage]: https://retr0h.github.io/git-url-parse/usage
[Documentation]: https://retr0h.github.io/git-url-parse/

## License

The [MIT][] License.
Expand Down
5 changes: 5 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ vars:
sh: git rev-parse --show-toplevel
MAIN_PACKAGE: main.go

includes:
docs:
taskfile: ./docs
dir: ./docs

tasks:
deps:
desc: Install dependencies
Expand Down
Binary file added asset/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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*
19 changes: 19 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Website

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

### Local Development

```
$ task 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

```
$ task build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.
72 changes: 72 additions & 0 deletions docs/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
version: "3"

tasks:
yarn:install:
desc: Setup Docusaurus locally
cmds:
- yarn install
sources:
- package.json
- yarn.lock

build:
desc: Build website
deps:
- yarn:install
cmds:
- yarn docusaurus build

start:
desc: Start website
deps:
- yarn:install
vars:
HOST: '{{default "localhost" .HOST}}'
PORT: '{{default "3001" .PORT}}'
cmds:
- yarn docusaurus start --no-open --host={{.HOST}} --port={{.PORT}}

serve:
desc: Preview website
deps:
- yarn:install
vars:
HOST: '{{default "localhost" .HOST}}'
PORT: '{{default "3001" .PORT}}'
cmds:
- yarn docusaurus serve --no-open --host={{.HOST}} --port={{.PORT}}

clean:
desc: Clean temp directories
cmds:
- rm -rf ./build

bump:
desc: Create a new documentation version
vars:
VERSION: '{{.VERSION}}'
cmds:
- yarn docusaurus docs:version {{.VERSION}}
requires:
vars:
- VERSION

deploy:
desc: Build and deploy Docusaurus
summary: Requires GIT_USER and GIT_PASS envs to be previous set
cmds:
- yarn docusaurus deploy

fmt:
desc: Reformat files whose formatting differs from `prettier`
deps:
- yarn:install
cmds:
- yarn prettier docs --write --config prettier.config.js

fmt:check:
desc: Check files whose formatting differs from `prettier`
deps:
- yarn:install
cmds:
- yarn prettier docs --check --config prettier.config.js
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')],
};
120 changes: 120 additions & 0 deletions docs/docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
sidebar_position: 6
---

# Contributing

Contributions to git-url-parse are very welcome, but we ask that you read this
document before submitting a PR.

:::note

This document applies to the [git-url-parse][] repository.

:::

## Before you start

- **Check existing work** - Is there an existing PR? Are there issues discussing
the feature/change you want to make? Please make sure you consider/address
these discussions in your work.
- **Backwards compatibility** - Will your change break existing git-url-parse
files? It is much more likely that your change will merged if it backwards
compatible. Is there an approach you can take that maintains this
compatibility? If not, consider opening an issue first so that API changes can
be discussed before you invest your time into a PR.

## 1. Setup

- **Go** - git-url-parse is written in [Go][]. We always support the latest two
major Go versions, so make sure your version is recent enough.
- **Node.js** - [Node.js][] is used to host git-url-parse's documentation server
and is required if you want to run this server locally.

## 2. Making changes

- **Code style** - Try to maintain the existing code style where possible. Go
code should be formatted by [`gofumpt`][gofumpt] and linted using
[`golangci-lint`][golangci-lint]. Any Markdown or TypeScript files should be
formatted and linted by [Prettier][]. This style is enforced by our CI to
ensure that we have a consistent style across the project. You can use the
`task fmt:check` command to lint the code locally and the `task fmt` command
to automatically fix any issues that are found.
- **Documentation** - Ensure that you add/update any relevant documentation. See
the [updating documentation](#updating-documentation) section below.
- **Tests** - Ensure that you add/update any relevant tests and that all tests
are passing before submitting the PR. See the [writing tests](#writing-tests)
section below.

### Running your changes

To run git-url-parse with working changes, you can use `go run main.go overlay`.

### Updating documentation

Git-url-parse uses [Docusaurus][] to host a documentation server. The code for
this is located in the git-url-parse repository. This can be setup and run
locally by using `task docs:start` (requires `nodejs` & `yarn`). All content is
written in Markdown and is located in the `docs/docs` directory. All Markdown
documents should have an 80 character line wrap limit (enforced by Prettier).

### Writing tests

When making a changes, consider whether new tests are required. These tests
should ensure that the functionality you are adding will continue to work in the
future. Existing tests may also need updating if you have changed
git-url-parse's behavior.

You may also consider adding unit tests for any new functions you have added.
The unit tests should follow the Go convention of being location in a file named
`*_test.go` in the same package as the code being tested.

Integration tests are located in the `tests` directory and executed by [Bats][].

## 3. Committing your code

Try to write meaningful commit messages and avoid having too many commits on the
PR. Most PRs should likely have a single commit (although for bigger PRs it may
be reasonable to split it in a few). Git squash and rebase is your friend!

If you're not sure how to format your commit message, check out [Conventional
Commits][]. This style is enforced, and is a good way to make your commit
messages more readable and consistent.

## 4. Submitting a PR

- **Describe your changes** - Ensure that you provide a comprehensive
description of your changes.
- **Issue/PR links** - Link any previous work such as related issues or PRs.
Please describe how your changes differ to/extend this work.
- **Examples** - Add any examples or screenshots that you think are useful to
demonstrate the effect of your changes.
- **Draft PRs** - If your changes are incomplete, but you would like to discuss
them, open the PR as a draft and add a comment to start a discussion. Using
comments rather than the PR description allows the description to be updated
later while preserving any discussions.

## FAQ

> I want to contribute, where do I start?
All kinds of contributions are welcome, whether its a typo fix or a shiny new
feature. You can also contribute by upvoting/commenting on issues or helping to
answer questions.

> I'm stuck, where can I get help?
If you have questions, feel free open a [Discussion][] on GitHub.

<!-- prettier-ignore-start -->
[git-url-parse]: https://github.com/retr0h/git-url-parse
[Go]: https://go.dev
[Node.js]: https://nodejs.org/en/
[gofumpt]: https://github.com/mvdan/gofumpt
[golangci-lint]: https://golangci-lint.run
[Prettier]: https://prettier.io/
[Docusaurus]: https://docusaurus.io
[Discussion]: https://github.com/retr0h/go-gilt/discussions
[Conventional Commits]: https://www.conventionalcommits.org
[Bats]: https://github.com/bats-core/bats-core
<!-- prettier-ignore-end -->
24 changes: 24 additions & 0 deletions docs/docs/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
slug: /
sidebar_position: 1
title: Home
---

# Git URL Parse

<img src="img/logo.png" align="left" width="20%" height="20%" />

This project is a golang port of an old project of mine [git-url-parse][], which
was donated to [coala][], and partially inspired by [go-git-url][].

It's usefulness may be limited, but I have a [fascination][] with revisiting old
projects.

<br clear="left"/>

<!-- prettier-ignore-start -->
[git-url-parse]: https://github.com/coala/git-url-parse
[coala]: https://coala.io/#/home?lang=Python
[fascination]: https://retr0h.github.io/gilt/
[go-git-url]: https://github.com/kubescape/go-git-url/tree/master
<!-- prettier-ignore-end -->
4 changes: 4 additions & 0 deletions docs/docs/resources/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
label: 'Resources'
collapsible: true # make the category collapsible
collapsed: false # keep the category open by default
Loading

0 comments on commit 6619bf4

Please sign in to comment.