Skip to content

Commit bcf41d0

Browse files
authored
Ease contributing by improving CONTRIBUTING.md and Makefile (#66)
* feat(makefile): add user-docs target and more docs * doc(CONTRIBUTING): move to root and add more details * fix: wrong escaping
1 parent 76bd8f3 commit bcf41d0

File tree

4 files changed

+128
-69
lines changed

4 files changed

+128
-69
lines changed

.github/CONTRIBUTING.md

Lines changed: 0 additions & 57 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Contributing to `obsidian.nvim`
2+
3+
Thanks for considering contributing!
4+
Please read this document to learn the various steps you should take before submitting a pull request.
5+
6+
## TL;DR
7+
8+
- Start an issue to discuss the planned changes
9+
- To submit a pull request
10+
- Start developing your feature in a branch
11+
- Make sure that your codes complies the `obsidian.nvim` code style, run
12+
`make chores`
13+
- The PR should contain
14+
- The code changes
15+
- Tests for the code changes
16+
- Documentation for the code changes (in the code itself and in the `README.md`)
17+
- `CHANGELOG.md` entry for the code changes
18+
19+
## Details
20+
21+
Note: we automate tedious tasks using a `Makefile` in the root of the repository.
22+
Just call `make` to see what you can do, or `make chores` to run the most important tasks on your code.
23+
You can override some parts of the `Makefile` by setting env variables.
24+
25+
### Local development with LuaLS and `plenary.nvim`
26+
27+
If you're using the [Lua Language Server](https://luals.github.io) (LuaLS) you'll probably want to add `plenary.nvim` as a workspace library since we rely heavily on plenary throughout the codebase.
28+
You can do this by adding a `.luarc.json` configuration file that looks like this:
29+
30+
```json
31+
{
32+
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
33+
"workspace.library": ["~/.local/share/nvim/lazy/plenary.nvim/"],
34+
"runtime.version": "Lua 5.1"
35+
}
36+
```
37+
38+
Make sure that the path there to plenary is correct for you.
39+
40+
### Keeping the `CHANGELOG.md` up-to-date
41+
42+
This project tries hard to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
43+
and we maintain a [`CHANGELOG`](https://github.com/obsidian-nvim/obsidian.nvim/blob/main/CHANGELOG.md)
44+
with a format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
45+
If your PR addresses a bug or makes any other substantial change,
46+
please be sure to add an entry under the "Unreleased" section at the top of `CHANGELOG.md`.
47+
Entries should always be in the form of a list item under a level-3 header of either "Added", "Fixed", "Changed", or "Removed" for the most part.
48+
If the corresponding level-3 header for your item does not already exist in the "Unreleased" section, you should add it.
49+
50+
### Formatting code
51+
52+
TL;DR: `make style`
53+
54+
Lua code should be formatted using [StyLua](https://github.com/JohnnyMorganz/StyLua).
55+
Once you have StyLua installed, you can run `make style` to automatically apply styling to all of the Lua files in this repo.
56+
57+
### Linting code
58+
59+
TL;DR: `make lint`
60+
61+
We use [luacheck](https://github.com/mpeterv/luacheck) to lint the Lua code.
62+
Once you have `luacheck` installed, you can run `make lint` to get a report.
63+
64+
### Running tests
65+
66+
TL;DR: `make test`
67+
68+
Tests are written in the `test/` folder and are run using the [Plenary](https://github.com/nvim-lua/plenary.nvim) test harness.
69+
Since Plenary is a dependency of `obsidian.nvim`, you probably already have it installed somewhere.
70+
To run the tests locally you'll need to know where it's installed, which depends on your plugin manager.
71+
In my case I use `Lazy.nvim` which puts Plenary at `~/.local/share/nvim/lazy/plenary.nvim/`.
72+
73+
### Building the vim user documentation
74+
75+
TL;DR: `make user-docs`
76+
77+
The Vim documentation lives at `doc/obsidian.txt`, which is automatically generated from the `README.md` using [panvimdoc](https://github.com/kdheepak/panvimdoc).
78+
**Please only commit documentation changes to the `README.md`, not `doc/obsidian.txt`.**
79+
80+
However you can test how changes to the README will affect the Vim doc by running `panvimdoc` locally.
81+
To do this you'll need install `pandoc` (e.g. `brew install pandoc` on Mac)
82+
and clone [panvimdoc](https://github.com/kdheepak/panvimdoc) (e.g. `git clone [email protected]:kdheepak/panvimdoc.git ../panvimdoc`).
83+
84+
This will build the Vim documentation to `/tmp/obsidian.txt`.
85+
86+
### Building the vim API documentation
87+
88+
TL;DR: `make api-docs`
89+
90+
The API docs lives in `doc/obsidian_api.txt` and is generated from the source code using [`mini.docs`](https://github.com/echasnovski/mini.doc).
91+
It is automatically generated via CI.

Makefile

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,30 @@ SHELL:=/usr/bin/env bash
33
.DEFAULT_GOAL:=help
44
PROJECT_NAME = "obsidian.nvim"
55
TEST = test/obsidian
6-
# Depending on your setup you have to override the locations at runtime.
6+
7+
# Depending on your setup you have to override the locations at runtime. E.g.:
8+
# make test PLENARY=~/path/to/plenary.nvim
9+
# make user-docs PANVIMDOC_PATH=~/path/to/panvimdoc/panvimdoc.sh
710
PLENARY = ~/.local/share/nvim/lazy/plenary.nvim/
811
MINIDOC = ~/.local/share/nvim/lazy/mini.doc/
12+
PANVIMDOC_PATH = ../panvimdoc/panvimdoc.sh
913

14+
################################################################################
15+
##@ Start here
16+
.PHONY: chores
17+
chores: style lint test ## Run develoment tasks (lint, style, test); PRs must pass this.
1018

1119
################################################################################
1220
##@ Developmment
13-
.PHONY: chores
14-
chores: style lint test ## Run all develoment tasks
21+
.PHONY: lint
22+
lint: ## Lint the code with luacheck
23+
luacheck .
24+
25+
.PHONY: style
26+
style: ## Format the code with stylua
27+
stylua --check .
28+
29+
# TODO: add type checking with lua-ls
1530

1631
.PHONY: test
1732
test: $(PLENARY) ## Run unit tests
@@ -24,6 +39,24 @@ test: $(PLENARY) ## Run unit tests
2439
$(PLENARY):
2540
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim.git $(PLENARY)
2641

42+
.PHONY: user-docs
43+
user-docs: ## Generate user documentation with panvimdoc
44+
@if [ ! -f "$(PANVIMDOC_PATH)" ]; then \
45+
echo "panvimdoc.sh not found at '$(PANVIMDOC_PATH)'. Make sure it is installed and check the path."; \
46+
exit 1; \
47+
fi
48+
$(PANVIMDOC_PATH) \
49+
--project-name obsidian \
50+
--input-file README.md \
51+
--toc false \
52+
--description 'a plugin for writing and navigating an Obsidian vault' \
53+
--vim-version 'NVIM v0.10.0' \
54+
--demojify false \
55+
--dedup-subheadings false \
56+
--shift-heading-level-by -1 \
57+
--ignore-rawblocks true \
58+
&& mv doc/obsidian.txt /tmp/
59+
2760
.PHONY: api-docs
2861
api-docs: $(MINIDOC) ## Generate API documentation with mini.doc
2962
MINIDOC=$(MINIDOC) nvim \
@@ -36,14 +69,6 @@ api-docs: $(MINIDOC) ## Generate API documentation with mini.doc
3669
$(MINIDOC):
3770
git clone --depth 1 https://github.com/echasnovski/mini.doc $(MINIDOC)
3871

39-
.PHONY: lint
40-
lint: ## Lint the code
41-
luacheck .
42-
43-
.PHONY: style
44-
style: ## format the code
45-
stylua --check .
46-
4772

4873
################################################################################
4974
##@ Helpers

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ And keep in mind that to reset a configuration option to `nil` you'll have to us
809809

810810
## Contributing
811811

812-
Please read the [CONTRIBUTING](https://github.com/obsidian-nvim/obsidian.nvim/blob/main/.github/CONTRIBUTING.md) guide before submitting a pull request.
812+
Please read the [CONTRIBUTING](https://github.com/obsidian-nvim/obsidian.nvim/blob/main/CONTRIBUTING.md) guide before submitting a pull request.
813813

814814
## Acknowledgement
815815

0 commit comments

Comments
 (0)