Skip to content

Commit

Permalink
fix: build mkdocs script and update doc (#68)
Browse files Browse the repository at this point in the history
* build mkdocs script for placing README.md at the root
* Update the docs
* Add "make all" to ease the setup locally (for new contributors)
  • Loading branch information
sumit-158 committed Nov 30, 2022
1 parent e8b1508 commit 9d05f20
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 23 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ jobs:
with:
python-version: 3.x
- name: Install mkdocs requirements
run: pip install mkdocs-material
run: |
pip install mkdocs-material
pip install mdx_truly_sane_lists
- name: Generate documentation
run: mkdocs build
run: |
bash ./build_mkdocs.sh
mkdocs build
- name: Deploy documentation to Github Pages 🚀
# we only deploy on push to main
if: |
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ tests:
${DOCKER_RUN} pytest .

checks: quality tests

# To ease the process for contributors
all: build_lang lint checks
29 changes: 19 additions & 10 deletions docs/README.md → README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://static.openfoodfacts.org/images/logos/off-logo-horizontal-dark.png?refresh_github_cache=1">
<source media="(prefers-color-scheme: light)" srcset="https://static.openfoodfacts.org/images/logos/off-logo-horizontal-light.png?refresh_github_cache=1">
<img height="80" src="https://static.openfoodfacts.org/images/logos/off-logo-horizontal-light.svg">
</picture>
</p>

## About Repo

![GitHub language count](https://img.shields.io/github/languages/count/openfoodfacts/facets-knowledge-panels?style=for-the-badge&color=brightgreen)
![GitHub top language](https://img.shields.io/github/languages/top/openfoodfacts/facets-knowledge-panels?style=for-the-badge&color=aqua)
![GitHub last commit](https://img.shields.io/github/last-commit/openfoodfacts/facets-knowledge-panels?style=for-the-badge&color=blue)
![Github Repo Size](https://img.shields.io/github/repo-size/openfoodfacts/facets-knowledge-panels?style=for-the-badge&color=aqua)

# facets-knowledge-panels

Providing knowledge panels for a particular Open Food Facts facet (category, brand, etc...)
Expand All @@ -12,17 +27,11 @@ Providing knowledge panels for a particular Open Food Facts facet (category, bra

- Join us on [Slack](https://openfoodfacts.slack.com/archives/C03LFRKLVBQ)
- Developer documentation
- [Project setup](./how-to-guides/Project-setup-locally.md)
- [Testing](./how-to-guides/Testing.md)
- [Contributing Guidelines](./how-to-guides/CONTRIBUTING.md)
- [API Documentation](./references/API%20references.md)

## About Repo
- [Project setup](./docs/how-to-guides/Project-setup-locally.md)
- [Testing](./docs/how-to-guides/Testing.md)
- [Contributing Guidelines](./docs/how-to-guides/CONTRIBUTING.md)
- [API Documentation](./docs/references/API%20references.md)

![GitHub language count](https://img.shields.io/github/languages/count/openfoodfacts/facets-knowledge-panels?style=for-the-badge&color=brightgreen)
![GitHub top language](https://img.shields.io/github/languages/top/openfoodfacts/facets-knowledge-panels?style=for-the-badge&color=aqua)
![GitHub last commit](https://img.shields.io/github/last-commit/openfoodfacts/facets-knowledge-panels?style=for-the-badge&color=blue)
![Github Repo Size](https://img.shields.io/github/repo-size/openfoodfacts/facets-knowledge-panels?style=for-the-badge&color=aqua)

## Contributors

Expand Down
6 changes: 6 additions & 0 deletions build_mkdocs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

# Renders markdown doc in docs to html in gh_pages

# copy README.md as the index but change links starting with ./docs/ to ./
sed -e 's|(\./docs/|(./|g' README.md > docs/index.md
9 changes: 3 additions & 6 deletions docs/how-to-guides/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,12 @@ git push origin <type>/<issue-issueNumber>/{<additional-fixes>}
- [Setup project locally](./Project-setup-locally.md)

#### Step 3
- [Testing the work before push](./Testing.md)

#### Step 4
```bash
## Committing and pushing your work

# recompile languages files
make build_lang

# format your code
make checks

# Ensure branch
git branch

Expand Down
10 changes: 9 additions & 1 deletion docs/how-to-guides/Project-setup-locally.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Project Setup
You may choose Docker-compose(recommended), or Through virtual env

### Through Docker
### Through Docker[Recommended]

- Prerequisite - [Docker](https://docs.docker.com/get-docker/)

Expand All @@ -11,11 +11,19 @@ to build:
```bash
docker-compose build
```
or
```bash
make docker_build
```

to run:
```bash
docker-compose up
```
or
```bash
make docker_up
```

- Visit `http://127.0.0.1/` with the endpoints or /docs for documentation

Expand Down
4 changes: 3 additions & 1 deletion docs/how-to-guides/Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@

### docker setup
```bash
make build_lang
docker-compose run --rm facets-api pytest tests
```
or
```bash
make tests
make all
```

### virtual env setup
- Checkout `tests` directory
```bash
make build_lang
pytest
```
4 changes: 2 additions & 2 deletions docs/references/API references.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Knowledge panel facets is a simple api that allow user to get knowledge-panels b

The api must be prefixed with this `/knowledge_panel?`.
The full url look like
`http://127.0.0.1:8000/knowledge_panel?facet_tag={desired-facet}&value_tag={facet-value}&lang_code={language}&country={desired-country}`
` https://facets-kp.openfoodfacts.org/knowledge_panel?facet_tag={desired-facet}&value_tag={facet-value}&lang_code={language}&country={desired-country}`

- API Documentation with interactive "try-out": http://127.0.0.1:8000/docs
- API Documentation with interactive "try-out": https://facets-kp.openfoodfacts.org/docs
28 changes: 27 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,30 @@ repo_url: https://github.com/openfoodfacts/facets-knowledge-panels
edit_uri: blob/main/docs/

theme:
name: material
name: material
logo: https://static.openfoodfacts.org/images/logos/off-logo-horizontal-light.svg
favicon: https://static.openfoodfacts.org/images/logos/off-logo-favicon-light.png
palette:

# Palette toggle for light mode
- scheme: default
toggle:
icon: material/brightness-7
name: Switch to dark mode

# Palette toggle for dark mode
- scheme: slate
toggle:
icon: material/brightness-4
name: Switch to light mode

markdown_extensions:
- footnotes
- pymdownx.highlight
- pymdownx.superfences
- toc:
# add permalink after titles
permalink: "#"
# this one allow to have two space indentation
# counts as nested list
- mdx_truly_sane_lists

0 comments on commit 9d05f20

Please sign in to comment.