Skip to content

Commit

Permalink
docs: ✏️ Refactor README and improve docs
Browse files Browse the repository at this point in the history
Create full guide and explanation pages in the docs and refactor
README.md

✅ Closes: #77
  • Loading branch information
abelsiqueira committed May 16, 2024
1 parent 868a111 commit a7d57b8
Show file tree
Hide file tree
Showing 17 changed files with 313 additions and 146 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ There is no related issue.

<!-- mark true if NA -->
<!-- leave PR as draft until all is checked -->
- [ ] I am following the [contributing guidelines](https://github.com/abelsiqueira/COPIERTemplate.jl/blob/main/docs/src/contributing.md)
- [ ] I am following the [contributing guidelines](https://github.com/abelsiqueira/COPIERTemplate.jl/blob/main/docs/src/90-contributing.md)
- [ ] Tests are passing
- [ ] Lint workflow is passing
- [ ] Docs were updated and workflow is passing
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ and this project adheres to [Semantic Versioning].
### Changed

- Update Cirrus CI image_family (#31)
- Prefix some doc files with a number and generate the pages programatically (#32)
- Prefix some doc files with a number and generate the pages programmatically (#32)
- Reestructure and improve the documentation (#77)

### Fixed

Expand Down Expand Up @@ -162,11 +163,13 @@ and this project adheres to [Semantic Versioning].
- Initial release

<!-- Links -->

[keep a changelog]: https://keepachangelog.com/en/1.0.0/
[semantic versioning]: https://semver.org/spec/v2.0.0.html

<!-- Versions -->
<!-- markdown-link-check-disable -->

[unreleased]: https://github.com/abelsiqueira/COPIERTemplate.jl/compare/v0.2.5...HEAD
[0.2.5]: https://github.com/abelsiqueira/COPIERTemplate.jl/compare/v0.2.5...HEAD
[0.2.4]: https://github.com/abelsiqueira/COPIERTemplate.jl/releases/tag/v0.2.4
Expand Down
155 changes: 23 additions & 132 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<p>
<img width="150" align="right" src="docs/src/assets/logo.png">
<img src="docs/src/assets/logo-wide.png" alt="COPIERTemplate.jl">
</p>

# COPIERTemplate.jl - Copier OPInionated Evolving Reusable Template
# Copier OPInionated Evolving Reusable Template

<div align="center">

<!-- markdown-link-check-disable -->
[![Stable Documentation](https://img.shields.io/badge/docs-stable-blue.svg)](https://abelsiqueira.github.io/COPIERTemplate.jl/stable)
[![In development documentation](https://img.shields.io/badge/docs-dev-blue.svg)](https://abelsiqueira.github.io/COPIERTemplate.jl/dev)
<!-- markdown-link-check-enable -->
[![Lint workflow Status](https://github.com/abelsiqueira/COPIERTemplate.jl/actions/workflows/Lint.yml/badge.svg?branch=main)](https://github.com/abelsiqueira/COPIERTemplate.jl/actions/workflows/Lint.yml?query=branch%3Amain)
[![Build Status](https://github.com/abelsiqueira/COPIERTemplate.jl/workflows/Test/badge.svg)](https://github.com/abelsiqueira/COPIERTemplate.jl/actions)
[![Test workflow status](https://github.com/abelsiqueira/COPIERTemplate.jl/actions/workflows/Test.yml/badge.svg?branch=main)](https://github.com/abelsiqueira/COPIERTemplate.jl/actions/workflows/Test.yml?query=branch%3Amain)
Expand All @@ -17,152 +17,44 @@
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.8350577.svg)](https://doi.org/10.5281/zenodo.8350577)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)

</div>

This is

- a [copier](https://copier.readthedocs.io) template/skeleton for Julia packages (see folder [template](template)); and
- a package created with the template that wraps `copier` in Julia using `PythonCall`.
- a package that wraps `copier` in Julia using `PythonCall`.

The template

- is opinionated but allows options;
- can be applied to existing packages (thanks to copier);
- is automatically reapplied through Pull Requests made by the Copier.yml workflow.

[![asciicast](https://asciinema.org/a/611189.svg)](https://asciinema.org/a/611189)

Additional wishlist

- Use as template for other templates (Maybe just use forks?)

**But why?**

Because I have around 50 packages that follow similar configuration (but not equal), and I don't want to go through all of them manually every time I have a small change.

**What about mass updates using the GitHub API?**

I have done that in the past, but now I want even less manual intervention.
This will still require manual installation for the first time, and will still allow verifying the pull requests.

## How to install

> **Warning**
>
> It is unknown if the package works on Windows due to an issue with unsupported paths.
> See [Issue #21](https://github.com/abelsiqueira/COPIERTemplate.jl/pull/21).
> If it doesn't work, let us know, and use the alternative installation.
1. Install this package, use the module and run `COPIERTemplate.generate(path)`.

Alternatively, this can also be installed directly via [copier](https://copier.readthedocs.io), with the command

```bash
copier copy https://github.com/abelsiqueira/COPIERTemplate.jl YourPackage.jl
```

Follow the instructions. In particular you will need a UUID. Your Linux might have `uuidgen` installed, but you can also use Julia:

```bash
using UUIDs
uuid4()
```

1. The resulting folder will not be a `git` package yet (to avoid trust issues), so you need to handle that yourself. First, install [`pre-commit`](https://pre-commit.com), and then issue:

```bash
cd YourPackage.jl
git init
git add .
pre-commit run -a # Fix possible pre-commit issues
git add .
git commit -m "First commit"
pre-commit install # Future commits can't be directly to main unless you use -n
```

It is common to have some pre-commit issues due to your package's name length triggering JuliaFormatter.
1. Create a repo on GitHub and push it
```bash
git remote add origin https://github.com/UserName/PackageName.jl
```
1. Create a `DOCUMENTER_KEY`, which will be used by for documentation purposes.
```bash
pkg> activate --temp
pkg> add DocumenterTools
julia> using DocumenterTools
julia> DocumenterTools.genkeys(user="UserName", repo="PackageName.jl")
```
Follow the instruction in the terminal.
1. Create a Personal Access Token to be used by the Copier workflow.
1. Go to <https://github.com/settings/tokens>.
1. Create a token with "Content", "Pull-request", and "Workflows" permissions.
1. Copy the Token.
1. Go to your YOUR_PACKAGE_URL/settings/secrets/actions.
1. Create a "New repository secret" named `COPIER_PAT`.
1. Before releasing, enable Zenodo integration at <https://zenodo.org/account/settings/github/>.
## What are all these files?
Since there are so many files, an explanation is in order.
### Basic package structure
This structure should be self-informative, as it is part of what most people use, with a few exceptions mentioned below.
- PackageName.jl/
- docs/
- src/
- 90-contributing.md
- 90-developer.md
- index.md
- 90-reference.md
- make.jl
- Project.toml
- src/
- PackageName.jl
- test/
- Project.toml
- runtests.jl
- LICENSE.md
- Project.toml
- README.md
The exceptions are:
<!-- agg https://asciinema.org/a/611189 docs/src/assets/demo.gif --speed 2.5 --cols 80 --rows 20 --font-family "JuliaMono" -->
[![asciicast](docs/src/assets/demo.gif)](https://asciinema.org/a/611189)

- `test/Project.toml`: This is supported for a while, and it looks better. Time will tell if it was a bad idea.
- `docs/src/90-contributing.md`: Also known as CONTRIBUTING.md, it explains how contributors can get involved in the project.
- `docs/src/90-developer.md`: Also known as README.dev.md, it explains how to setup your local environment.
## Quickstart

### Linting and Formatting
Install this package, then:

The most important file related to linting and formatting is `.pre-commit-config.yaml`, which is the configuration for [pre-commit](https://pre-commit.com).
It defines a list of linters and formatters for Julia, Markdown, YAML, and JSON.
```julia-repl
julia> using COPIERTemplate
julia> COPIERTemplate.generate("YourPackage.jl")
```

It requires installing `pre-commit` (I recommend installing it globally with `pipx`).
Installing pre-commit (`pre-commit install`) will make sure that it runs right the relevant hooks before commiting.
Additionally, if you run `pre-commit run -a`, it runs all hooks, which can be used for Linting.
Or, you can use [copier](https://copier.readthedocs.io) directly:

Some hooks in the `.pre-commit-config.yaml` file have configuration files of their own:
`.JuliaFormatter.toml`, `.markdownlint.json`, `.markdown-link-config.json`, and `.yamllint.yml`.
```bash
copier copy https://github.com/abelsiqueira/COPIERTemplate.jl YourPackage.jl
```

Also slightly related, is the `.editorconfig` file, which tells your editor, if you install the coorect plugin, how to format some things.
If you like what you see, check the [full usage guide](@ref full_guide).

### GitHub Workflows
## Contributing

The select a few workflows, with a strong possibility of expanding in the future:
If you would like to get involved in the COPIERTemplate growth, please check our [contributing guide](docs/src/90-contributing.md). We welcome contributions of many types, including coding, reviewing, creating issues, creating tutorials, interacting with users, etc. Make sure to follow our [code of conduct](CODE_OF_CONDUCT.md).

- CompatHelper.yml: Should be well known by now. It checks that your Project.toml compat entries are up-to-date.
- Copier.yml: This will periodically check the template for updates. If there are updates, this action creates a pull request updating your repo.
- Docs.yml: Build the docs. Only runs when relevant files change.
- Lint.yml: Run the linter and formatter through the command `pre-commit run -a`.
- TagBot.yml: Create GitHub releases automatically after your new release is merged on the Registry.
- Test.yml: Run the tests.
If your interest is in developing the package, check the [development guide](docs/src/90-developer.md) as well.

## Users and Examples

Expand All @@ -171,4 +63,3 @@ Feel free to create a pull request to add your repo.

- This package itself uses the template.
- [COPIERTemplateExample.jl](https://github.com/abelsiqueira/COPIERTemplateExample.jl)
- [JSOTemplate.jl](https://github.com/JuliaSmoothOptimizers/JSOTemplate.jl)
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Documenter

DocMeta.setdocmeta!(COPIERTemplate, :DocTestSetup, :(using COPIERTemplate); recursive = true)

const page_rename = Dict("developer.md" => "Dev setup")
const page_rename = Dict("developer.md" => "Developer docs")

function nice_name(file)
file = replace(file, r"^[0-9]*-" => "")
Expand Down
102 changes: 102 additions & 0 deletions docs/src/10-full-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# [Full guide](@id full_guide)

Welcome to **full usage guide** of COPIERTemplate.

## Before installing

1. We highly recommend that you install [`pre-commit`](https://pre-commit.com). Our whole linting is based on that tool, so you might want to adopt it locally.
1. Decide if you are going to install `copier` or use our Julia interface.
1. If you use `copier` directly, find a UUID version 4 generator.
- On Linux and MacOS, you can run `uuidgen`
- On Julia, you can run `using UUIDs; uuid4()`
- Online, you can try [uuidgenerator.net](https://www.uuidgenerator.net/version4)

## Installation

To install with COPIERTemplate.jl, install the package, use it, and run `COPIERTemplate.generate(path)`.

Alternatively, this can also be installed directly via [copier](https://copier.readthedocs.io), with the command

```bash
copier copy https://github.com/abelsiqueira/COPIERTemplate.jl YourPackage.jl
```

Many questions will be asked. The explanation on them should be sufficient (if they aren't, please let us know).

## Post-installation

### Add to GitHub

The resulting folder will not be a `git` package yet (to avoid trust issues), so you need to handle that yourself.
Here is a short example:

```bash
cd YourPackage.jl
git init
git add .
pre-commit run -a # Try to fix possible pre-commit issues
git add .
git commit -m "First commit"
pre-commit install # Future commits can't be directly to main unless you use -n
```

It is common to have some pre-commit issues due to your package's name length triggering JuliaFormatter.

Create a repo on GitHub and push your code to it.

```bash
git remote add origin https://github.com/UserName/PackageName.jl
git push -u origin main
```

### Documentation

Go to your package setting on GitHub and find the "Pages" link.
You should see an option to set the **Source** to "Deploy from a branch", and select the branch to be "gh-pages" and to deploy from the "/ (root)".

After circa 1 minute, you can check that the documentation was built properly.
You will still need to set a `DOCUMENTER_KEY` to build the documentation from the tags automatically when using TagBot (which we do by default).
Do the following:

```bash
pkg> activate --temp
pkg> add DocumenterTools
julia> using DocumenterTools
julia> DocumenterTools.genkeys(user="UserName", repo="PackageName.jl")
```

Follow the instruction in the terminal.

### Add key for Copier.yml workflow (or delete it)

You can reapply the template in the future. This is normally a manual job, specially because normally there are conflicts.
That being said, we are experimenting with having a workflow that automatically checks whether there are updates to the template and reapplies it.
A Pull Request is created with the result.

!!! warning
This is optional, and in development, so you might want to delete the workflow instead.

If you decide to use, here are the steps to set it up:

1. Create a Personal Access Token to be used by the Copier workflow.
1. Go to <https://github.com/settings/tokens>.
1. Create a token with "Content", "Pull-request", and "Workflows" permissions.
1. Copy the Token.
1. Go to your `YOUR_PACKAGE_URL/settings/secrets/actions`.
1. Create a "New repository secret" named `COPIER_PAT`.

### CITATION.cff and Zenodo deposition

Update your `CITATION.cff` file with correct information.
You can use [cffinit](https://citation-file-format.github.io/cff-initializer-javascript/#/) to generate it easily.

Before releasing, enable Zenodo integration at <https://zenodo.org/account/settings/github/> to automatically generate a deposition of your package, i.e., archive a version on Zenodo and generate a DOI.

### Update README.md

1. Update the badges
1. Add a description

### Enable discussions

Enable GitHub discussions.
Loading

0 comments on commit a7d57b8

Please sign in to comment.