Skip to content

Commit

Permalink
refactor: use template to generate documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
florianvazelle committed Dec 30, 2023
1 parent d503bc4 commit bcf6c36
Show file tree
Hide file tree
Showing 36 changed files with 2,507 additions and 313 deletions.
3 changes: 1 addition & 2 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
[codespell]
skip = assets/**
ignore-words-list = lod,LOD
skip = addons/gd-plug/**,addons/gut/**
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Godot

GODOT_VERSION=4.1.3
GODOT_VERSION=4.2.1

# Addon

Expand Down
16 changes: 11 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Properly detect languages on Github.
*.gd linguist-language=GDScript

# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf
*.gd linguist-language=GDScript

# The above only works properly for Git 2.10+, so for older versions
# we need to manually list the binary files we don't want modified.
*.mp3 binary
*.png binary
*.hdr binary

# Exclude all top-level files and directories (except addons) from zip downloads.
# This makes installing through the AssetLib easier, because no files and folders
# need to be unchecked.

/** export-ignore
/addons/godot-gherkin !export-ignore
/addons/godot-gherkin/** !export-ignore
/** export-ignore
/addons/godot-autogen-docs !export-ignore
/addons/godot-autogen-docs/** !export-ignore
17 changes: 12 additions & 5 deletions .github/workflows/release-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ jobs:
- name: Load dotenv
run: just ci-load-dotenv

# Retry multiple times, sometimes in CI, gdlint raise "file exists"
- name: Check
run: just fmt
uses: nick-fields/retry@v2
with:
timeout_minutes: 1
max_attempts: 3
command: just fmt

- name: Ensure version is equal to tag
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -31,8 +36,10 @@ jobs:
runs-on: ubuntu-22.04
timeout-minutes: 30

matrix:
- godot_version: ['4.0.4', '4.1.3']
strategy:
fail-fast: true
matrix:
godot_version: ['4.1.3', '4.2.1']

steps:
- uses: actions/checkout@v4
Expand All @@ -42,8 +49,8 @@ jobs:
with:
python-version: '3.10'

- name: Check
run: just doc
- name: Test
run: just test
env:
GODOT_VERSION: ${{ matrix.godot_version }}

Expand Down
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ gfxrecon_capture_*
.mono/
data_*/

# gd-plug
.plugged/
addons/*
!addons/gd-plug/
!addons/godot-autogen-docs/

# Python-specific ignores
venv/

# Export output
dist/
build/
override.cfg

# Docs output
reference.json
site/
10 changes: 10 additions & 0 deletions .gutconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dirs": [
"res://test/"
],
"prefix": "",
"suffix": ".test.gd",
"include_subdirs": true,
"log_level": 1,
"should_exit": true
}
11 changes: 10 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ repos:
entry: gdformat
language: system
files: \.gd$
exclude: |
(?x)^(
addons/gd-plug/|
plug.gd
)
- id: check-shaders
name: check shaders
entry: clang-format
Expand All @@ -55,9 +60,13 @@ repos:
- -i
language: system
files: \.gdshader$
exclude: ^addons/
- id: lint-gdscript
name: lint gdscript
entry: gdlint
language: system
files: \.gd$
exclude: |
(?x)^(
addons/gd-plug/|
plug.gd
)
11 changes: 11 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@ Files: *
Copyright: 2022-present Florian Vazelle
License: MIT

# Addons

Files: addons/gd-plug/*
Copyright: 2021 Tan Jian Ping
License: MIT
Source: https://github.com/imjp94/gd-plug

Files: addons/gut/*
Copyright: 2018 Tom "Butch" Wesley
License: MIT
Source: https://github.com/bitwes/Gut
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
### Security
### Dependencies

- Bump `actions/setup-python` from 4 to 5 ([#2](https://github.com/MechanicalFlower/godot-autogen-docs/pull/2))
26 changes: 20 additions & 6 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,17 @@ install-godot:
install-addons:
[ -f plug.gd ] && just godot --headless --script plug.gd install || true

# Workaround from https://github.com/godotengine/godot/pull/68461
# Import game resources
import-resources:
just godot --headless --export-pack null /dev/null
# timeout 60 just godot --editor || true
# just godot --headless --quit --editor

# Updates the addon version
@bump-version:
echo "Update version in the plugin.cfg"
sed -i "s,version=.*$,version=\"{{ addon_version }}\",g" ./addons/{{ addon_name }}/plugin.cfg
# echo "Update version in the plugin.cfg"
# sed -i "s,version=.*$,version=\"{{ addon_version }}\",g" ./addons/{{ addon_name }}/plugin.cfg

# Godot binary wrapper
@godot *ARGS: makedirs install-godot
Expand Down Expand Up @@ -110,12 +117,19 @@ publish:
gh release create "{{ addon_version }}" --title="v{{ addon_version }}" --generate-notes
# TODO: Add a asset-lib publish step

cli *ARGS:
just godot --editor --headless --quit --script addons/godot-autogen-docs/cli.gd {{ ARGS }}

# Generate documentation
doc:
just godot --editor --headless --quit --script addons/godot-autogen-docs/reference_collector_cli.gd
just godot --headless --quit --script addons/godot-autogen-docs/markdown.gd
just godot --editor --headless --quit --script addons/godot-autogen-docs/cli.gd readthedocs -ddir=res://addons/godot-autogen-docs -doutdir=res://docs/dev-guide/api-ref/
just venv pip install mkdocs==1.5.3 mkdocs-literate-nav==0.6.1
just venv mkdocs build

serve:
just venv pip install mkdocs==1.5.3 mkdocs-literate-nav==0.6.1
# Start serving the documentation
serve: doc
just venv mkdocs serve

# Run unit tests
test: install-addons import-resources
just godot --headless --script addons/gut/gut_cmdln.gd -gconfig=.gutconfig.json
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Godot Autogen Docs

![Godot Badge](https://img.shields.io/badge/godot-4.0|4.1-blue?logo=Godot-Engine&logoColor=white)
![Godot Badge](https://img.shields.io/badge/godot-4.1%20%7C%204.2-blue?logo=Godot-Engine&logoColor=white)
![license](https://img.shields.io/badge/license-MIT-green?logo=open-source-initiative&logoColor=white)
![reuse](./.reuse/REUSE-compliant.svg)

Expand All @@ -16,14 +16,20 @@ Godot addon that automatically turns your code

### Usage

To generate a `reference.json`, run:
```
godot --editor --headless --quit --script addons/godot-autogen-docs/reference_collector_cli.gd
```
$ just godot --editor --headless --quit --script addons/godot-autogen-docs/cli.gd help
And to turn this JSON file into markdown, run:
```
godot --headless --quit --script addons/godot-autogen-docs/markdown.gd
Usage:
godot --editor --headless --quit --script res://addons/godot-autogen-docs/cli.gd <command> [<options> ...]
Commands:
help Display this text
markdown Export documentation to markdown
readthedocs Export documentation to markdown compatible with the readthedocs theme
Options:
-ddir Comma delimited list of directories to collect files from
-doutdir A directory for saving documentation files
```

## Contributing
Expand Down
Loading

0 comments on commit bcf6c36

Please sign in to comment.