Skip to content

Commit 689294e

Browse files
authored
Documentation overhaul - Fixing formatting issues, autodoc implementation, and added variables for versions. (#3734)
Closes #3639. This is a bit of an overhaul of the docs to make them more easy to utilize. This changes include: - Removal of overhanging public aspects of the documentation - Reformatting of terminal commands to allow for easy copy & pasting - Updating points of contact - Screenshot Updates - Automated code API documentation. [Google's docstring style](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#38-comments-and-docstrings) should be used. - Added variables for things like software versions & packages. - Unless python & node version are manually specified, when docs are built these will be pulled from [`.nvmrc`](https://github.com/HyphaApp/hypha/blob/main/.nvmrc) & [`.python-version`](https://github.com/HyphaApp/hypha/blob/main/.python-version) - Consolidated the production and development guides into one location (both under `Setup` rather than one under `Getting Started` and one under `Setup`), and updated them to be similar to one another. - Added different steps for getting Hypha development deployed under multiple OSs
1 parent ca68ee5 commit 689294e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+754
-356
lines changed

.github/workflows/deploy-docs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
- name: Deploy docs
2525
uses: mhausenblas/mkdocs-deploy-gh-pages@master
2626
env:
27+
GEN_REF_PAGES: true
2728
GITHUB_TOKEN: ${{ github.token }}
2829
CUSTOM_DOMAIN: docs.hypha.app
2930
CONFIG_FILE: mkdocs.yml

CODE_OF_CONDUCT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
5555
## Enforcement
5656

5757
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58-
reported by contacting the project team at [email protected] and/or [email protected]. All
58+
reported by contacting the project team at [email protected]. All
5959
complaints will be reviewed and investigated and will result in a response that
6060
is deemed necessary and appropriate to the circumstances. The project team is
6161
obligated to maintain confidentiality with regard to the reporter of an incident.

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ We are grateful to organizations that have chosen to implement Hypha and appreci
5757
- [Remote Inning](https://www.remoteinning.com/)
5858
- [Maxwell Pearl](https://maxwellpearl.com/)
5959
- [Psycle](https://psycle.com/)
60-
- [Simply Secure](https://simplysecure.org/)
60+
- [Superbloom](https://superbloom.design/)
6161
- [Throneless Technology](https://throneless.tech/)
6262
- [Torchbox](https://www.torchbox.com/)
6363

@@ -75,4 +75,4 @@ We are grateful to organizations that have chosen to implement Hypha and appreci
7575
* Community forum (Discourse): https://we.hypha.app/
7676
* Chat (Zulip): https://chat.hypha.app/
7777
* Why Hypha? [Hyphae](https://en.wikipedia.org/wiki/Mycorrhizal_network):** long, branching ecosystem enriching organisms that form interconnected networks to collectively exchange resources. Hopefully, Hypha helps it's users do the same.
78-
* Copyright (C) 2021 - Open Technology Fund
78+
* Copyright (C) 2024 - Open Technology Fund

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ We take security very seriously. We welcome any peer review of our 100% open sou
44

55
## Where should I report security issues?
66

7-
In order to give the community time to respond and upgrade we strongly urge you report all security issues privately. Please email [email protected] and/or [email protected] with details and reproduction steps. Security issues *always* take precedence over bug fixes and feature work. We can and do mark releases as "urgent" if they contain serious security fixes.
7+
In order to give the community time to respond and upgrade we strongly urge you report all security issues privately. Please email [email protected] with details and reproduction steps. Security issues *always* take precedence over bug fixes and feature work. We can and do mark releases as "urgent" if they contain serious security fixes.
88

99
For a list of recent security commits, check [our GitHub commits prefixed with SECURITY](https://github.com/HyphaApp/hypha/search?utf8=%E2%9C%93&q=SECURITY&type=Commits).
1010

docker/entrypoint.dev.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ python3 manage.py migrate
1111
python3 manage.py wagtailsiteupdate hypha.test 8090
1212

1313
# Start gunicorn server.
14-
gunicorn hypha.wsgi:application --env DJANGO_SETTINGS_MODULE=hypha.settings.dev --reload --bind 0.0.0.0:9001
14+
gunicorn hypha.wsgi:application --env DJANGO_SETTINGS_MODULE=hypha.settings.dev --threads 3 --reload --bind 0.0.0.0:9001
1515

1616
exec "$@"
-108 KB
Binary file not shown.

docs/assets/how-to-login-nav.png

2.38 KB
Loading
219 KB
Loading
254 KB
Loading
235 KB
Loading

docs/getting-started/architecture.md

+26-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
Hypha consists of three distinctive components:
2-
3-
1. First is the **Apply Site**, where people seeking for funds can apply by submitting their applications, the submission goes through different stages before it being approved for funding. After the applications are approved, they can be converted to a project. Apply site allows to manage the lifecycle of a project starting from a PAF to contracting to invoicing.
4-
5-
2. Then the **Admin or Wagtail Admin**, is used to create custom forms, setup funds/labs and workflow around them. Think of it as the back-office of for your submissions and projects.
61

2+
## Diagram
73

84
```
95
Integrations
@@ -16,16 +12,33 @@ Hypha consists of three distinctive components:
1612
1713
1814
19-
┌───────────┐
20-
│APPLY SITE │◀───┐ ┌───────────┐
21-
└───────────┘ │ │ DJANGO │ ┌───────────┐
22-
├────│ BACKEND │◀────────│PostgresSQL│
23-
┌───────────┐ │ └───────────┘ └───────────┘
24-
│ ADMIN │◀───┘
25-
└───────────┘
15+
┌────────────┐ Databases
16+
│ APPLY SITE │◀────┐ ┌ ─ ─ ─ ─ ─ ─ ─ ─┐
17+
└────────────┘ │ ┌────────────┐ ╎ ┌────────────┐ ╎
18+
├──────│ Django / │◀───────╎ │ PostgreSQL │ ╎
19+
┌────────────┐ │ │ Wagtail │ ╎ └────────────┘ ╎
20+
│ WAGTAIL │◀────┘ └────────────┘ └─ ─ ─ ─ ─ ─ ─ ─ ┘
21+
│ ADMIN │
22+
└────────────┘
2623
```
2724

28-
## Django
25+
-----------
26+
27+
## Main Components
28+
29+
### Apply Site
30+
31+
Where people seeking for funds can apply by submitting their applications, the submission goes through different stages before it being approved for funding. After the applications are approved, they can be converted to a project. Apply site allows to manage the lifecycle of a project starting from a PAF to contracting to invoicing.
32+
33+
### Wagtail Admin
34+
35+
Used to create custom forms, setup funds/labs and workflow around them. Think of it as the back-office of for your submissions and projects.
36+
37+
-----------
38+
39+
## Under The Hood
40+
41+
### Django
2942

3043
Hypha is built on top of the Django Web Framework. All the pages are rendered server side. It uses wagtail CMS for creating and managing custom application forms, public pages and settings.
3144

docs/getting-started/contributing/code-contributions.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Creating Pull Requests
44

5-
Found a bug and know how to fix it? Have some design wireframes to improve some usability issues? Traslated Hypha into another language? Built a new feature you want to add? Please submit an issue or create a pull request on [GitHub](https://github.com/HyphaApp/hypha/issues).
5+
Found a bug and know how to fix it? Have some design wireframes to improve some usability issues? Translated Hypha into another language? Built a new feature you want to add? Please submit an issue or create a pull request on [GitHub](https://github.com/HyphaApp/hypha/issues).
66

77
Guidance for contributing code:
88

docs/getting-started/contributing/submitting-changes.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ We use pull requests for all changes. No commits are done directly in to the mai
1010

1111
4. **Link the PR to the corresponding issue** - A common way is to add "Fixes \#1234" at the top of the PR description. See [Linking a pull request to an issue](https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)
1212

13-
5. **Add a reviewer** - If noting else has been agreed upon add Fredrik Jonsson [@frjo](https://github.com/frjo).
13+
5. **Add a reviewer** - If nothing else has been agreed upon add Fredrik Jonsson [@frjo](https://github.com/frjo).
1414

1515
## Git command examples
1616

@@ -20,17 +20,17 @@ First check out master and do a git pull ot get all the latest updates.
2020

2121
Then create a new branch and do a checkout of it.
2222

23-
```text
24-
$ git checkout master
25-
$ git pull
26-
$ git checkout -b fix/gh-1234-fixing-thing-a
23+
```shell
24+
git checkout master
25+
git pull
26+
git checkout -b fix/gh-1234-fixing-thing-a
2727
```
2828

2929
### Adding commits
3030

31-
```text
32-
$ git add
33-
$ git commit -m "A good commit message."
31+
```shell
32+
git add
33+
git commit -m "A good commit message."
3434
```
3535

3636
### Pushing branch first time to GitHub
@@ -39,9 +39,9 @@ First make sure we are in the correct branch. Then push the branch to origin, i.
3939

4040
(Pushing to `HEAD` is equivalent to pushing to a remote branch having the same name as your current branch.)
4141

42-
```text
43-
$ git checkout fix/gh-1234-fixing-thing-a
44-
$ git push -u origin HEAD
42+
```shell
43+
git checkout fix/gh-1234-fixing-thing-a
44+
git push -u origin HEAD
4545
```
4646

4747
The message in the Terminal will contain the URL to create an PR. On most systems you can Command/CTRL click that to open it directly in your default browser.
@@ -50,12 +50,12 @@ The message in the Terminal will contain the URL to create an PR. On most system
5050

5151
Checkout master and update it. Checkout the branch you are working on and issue the command to rebase it from master. If that resulted in any changes you will then need to do a force push to GitHub.
5252

53-
```text
54-
$ git checkout master
55-
$ git pull
56-
$ git checkout fix/gh-1234-fixing-thing-a
57-
$ git rebase master
58-
$ git push --force
53+
```shell
54+
git checkout master
55+
git pull
56+
git checkout fix/gh-1234-fixing-thing-a
57+
git rebase master
58+
git push --force
5959
```
6060

6161
Read more about [Git rebase](https://www.atlassian.com/git/tutorials/rewriting-history/git-rebase).

docs/getting-started/deployment.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Deploying Hypha
2+
3+
Navigating to the setup guide [production](../setup/deployment/production/stand-alone.md) or [development](../setup/deployment/development/stand-alone.md)

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ View our [Roadmap](https://github.com/HyphaApp/hypha/wiki/Roadmap) for upcoming
3131
## Technology
3232

3333
* Built with [Django](https://www.djangoproject.com/), PostgreSQL and [Wagtail](https://wagtail.io/)
34-
* Deploy with [Heroku](./setup/deployment/heroku.md), [Docker](./setup/deployment/docker.md), or [your own server](./setup/deployment/stand-alone.md).
34+
* Deploy with [Heroku](./setup/deployment/production/heroku.md), [Docker](./setup/deployment/production/docker.md), or [your own server](./setup/deployment/production/stand-alone.md).

docs/scripts/doc_macros.py

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import re
2+
3+
# The versioning file for python
4+
PYTHON_VERSION_FILE = ".python-version"
5+
6+
# The versioning file for node (used by nvm)
7+
NVM_VERSION_FILE = ".nvmrc"
8+
9+
# RegEx string recommended for semver:
10+
# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
11+
SEMVER_REGEX = r"^(?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"
12+
13+
14+
# Exception classes
15+
class InvalidVersionException(Exception):
16+
"""A version specified in `PYTHON_VERSION_FILE` or `NVM_VERSION_FILE` are of invalid format."""
17+
18+
19+
class VersionFileNotFoundError(FileNotFoundError):
20+
"""A version file specified in `PYTHON_VERSION_FILE` or `NVM_VERSION_FILE` was not found."""
21+
22+
23+
def define_env(env):
24+
"""
25+
Where mkdocs-macros are defined. For more info, see:
26+
https://mkdocs-macros-plugin.readthedocs.io/en/latest/macros/
27+
"""
28+
29+
# If python & node versions are left blank in mkdocs.yml, attempt to automatically populate them
30+
31+
if env.variables.versions["python"]["version"] is None:
32+
py_ver = get_python_version()
33+
# Remove the patch number from the docs versioning
34+
env.variables.versions["python"]["version"] = ".".join(py_ver.split(".")[:-1])
35+
36+
if env.variables.versions["python"]["packages"]["macos"] is None:
37+
env.variables.versions["python"]["packages"][
38+
"macos"
39+
] = f"python@{'.'.join(py_ver.split('.')[:-1])}"
40+
41+
if env.variables.versions["node"]["version"] is None:
42+
node_ver = get_node_version()
43+
44+
# Remove the patch number from the docs versioning
45+
env.variables.versions["node"]["version"] = ".".join(node_ver.split(".")[:-1])
46+
47+
48+
def get_python_version() -> str:
49+
"""
50+
Returns the semantic version of the current Python runtime based off the specified `PYTHON_VERSION_FILE`
51+
"""
52+
version: str
53+
54+
try:
55+
with open(PYTHON_VERSION_FILE, "r") as py_ver:
56+
version = py_ver.read()
57+
58+
if not valid_semver(version):
59+
raise InvalidVersionException(f'Unrecognized Python version: "{version}"!')
60+
61+
return version
62+
except FileNotFoundError as err:
63+
raise VersionFileNotFoundError(
64+
f'Failed to find Python version file at "{PYTHON_VERSION_FILE}"'
65+
) from err
66+
67+
68+
def get_node_version() -> str:
69+
"""
70+
Returns the semantic version of the current Node runtime based off the specified `NVM_VERSION_FILE`
71+
"""
72+
version: str
73+
74+
try:
75+
with open(NVM_VERSION_FILE, "r") as nvm_ver:
76+
version = nvm_ver.read()
77+
78+
# Node version is usually in the format of "vX.X.X"
79+
if version.startswith("v"):
80+
version = version[1:]
81+
82+
if not valid_semver(version):
83+
raise InvalidVersionException(f'Unrecognized Node version: "{version}"!')
84+
85+
return version
86+
except FileNotFoundError as err:
87+
raise VersionFileNotFoundError(
88+
f'Failed to find Node version file at "{NVM_VERSION_FILE}"'
89+
) from err
90+
91+
92+
def valid_semver(version: str) -> bool:
93+
"""
94+
Uses the suggested semver regex pattern to validate that the given version string is valid.
95+
"""
96+
regex_match = re.match(SEMVER_REGEX, version)
97+
98+
if regex_match is None:
99+
return False
100+
101+
return True

docs/scripts/gen_ref_pages.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
"""
2+
Generate reference pages for the API. Uses concurrency to speed things up, and
3+
ensures that generation of references pages in enabled in the environment via
4+
the `GEN_REF_PAGES` var.
5+
6+
For more info on how this is done, see:
7+
https://mkdocstrings.github.io/recipes/#automatic-code-reference-pages
8+
"""
9+
10+
import concurrent.futures
11+
import os
12+
from pathlib import Path
13+
14+
import mkdocs_gen_files
15+
16+
# The code source directory
17+
src = Path(__file__).parent.parent.parent / "hypha"
18+
skip_folders = ["public", "tests", "migrations"]
19+
20+
21+
def process_path(path):
22+
module_path = path.relative_to(src).with_suffix("")
23+
doc_path = path.relative_to(src).with_suffix(".md")
24+
full_doc_path = Path("references/API", doc_path)
25+
parts = tuple(module_path.parts)
26+
# Don't document any code in public/ or tests/ directories
27+
for skip_folder in skip_folders:
28+
if skip_folder in parts:
29+
return
30+
if parts[-1] == "__init__":
31+
parts = parts[:-1]
32+
doc_path = doc_path.with_name("index.md")
33+
full_doc_path = full_doc_path.with_name("index.md")
34+
elif parts[-1] in ["__main__"]:
35+
return
36+
# Create the required files on build with mkdocs_gen_files, see:
37+
# https://oprypin.github.io/mkdocs-gen_files/
38+
if len(parts) > 0:
39+
with mkdocs_gen_files.open(full_doc_path, "w") as fd:
40+
identifier = f"::: hypha.{'.'.join(parts)}"
41+
fd.write(identifier)
42+
mkdocs_gen_files.set_edit_path(full_doc_path, path)
43+
44+
45+
def generate_pages():
46+
with concurrent.futures.ThreadPoolExecutor() as executor:
47+
list(executor.map(process_path, sorted(src.rglob("*.py"))))
48+
49+
50+
# Confirm `GEN_REF_PAGES` is enabled in the env
51+
if os.getenv("GEN_REF_PAGES", False):
52+
generate_pages()

0 commit comments

Comments
 (0)