Skip to content

Commit

Permalink
Merge pull request #1 from earthobservations/dev
Browse files Browse the repository at this point in the history
Add first version of Goethe
  • Loading branch information
gutzbenj committed Oct 23, 2022
2 parents 6bc9ec4 + eae0771 commit 1473642
Show file tree
Hide file tree
Showing 30 changed files with 2,400 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms
github: ["gutzbenj"]
patreon: "earthobservations"
custom: ['paypal.me/BenjaminGutzmann']
9 changes: 9 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage:
status:
project:
default:
target: 75%

patch:
default:
target: 75%
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
versioning-strategy: lockfile-only
57 changes: 57 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Coverage
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
run:
runs-on: ubuntu-latest
name: Check code coverage
steps:
- name: Acquire sources
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
architecture: x64

- name: Setup Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Get Poetry cache directory
id: poetry-cache-dir
run: |
echo "::set-output name=dir::$(poetry config cache-dir)"
- name: Apply cache
id: poetry-cache-flag
uses: actions/cache@v3
env:
# Increase this value to reset cache if `poetry.lock` has not changed.
CACHE_NUMBER: 1
with:
path: ${{ steps.poetry-cache-dir.outputs.dir }}
key: poetry-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}-${{ env.CACHE_NUMBER }}

- name: Install library
run: poetry install

- name: Generate coverage report
run: |
poetry run pytest --cov=goethe tests/
poetry run coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: false
45 changes: 45 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Linter
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
run:
runs-on: ubuntu-latest
name: Code style checks
steps:
- name: Acquire sources
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
architecture: x64

- name: Setup Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Get Poetry cache directory
id: poetry-cache-dir
run: |
echo "::set-output name=dir::$(poetry config cache-dir)"
- name: Apply cache
id: poetry-cache-flag
uses: actions/cache@v3
env:
# Increase this value to reset cache if `poetry.lock` has not changed.
CACHE_NUMBER: 1
with:
path: ${{ steps.poetry-cache-dir.outputs.dir }}
key: poetry-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}-${{ env.CACHE_NUMBER }}

- name: Install library
run: poetry install --no-root

- name: Run lint on code
run: poetry run poe lint
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release
on:
release:
types: [ published ]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
architecture: x64

- name: Setup Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Get Poetry cache directory
id: poetry-cache-dir
run: |
echo "::set-output name=dir::$(poetry config cache-dir)"
- name: Apply cache
id: poetry-cache-flag
uses: actions/cache@v3
env:
# Increase this value to reset cache if `poetry.lock` has not changed.
CACHE_NUMBER: 1
with:
path: ${{ steps.poetry-cache-dir.outputs.dir }}
key: poetry-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}-${{ env.CACHE_NUMBER }}

- name: Install library
run: poetry install

- name: Build
run: poetry build

- name: Publish
run: poetry publish --username=__token__ --password=${{ secrets.PYPI_TOKEN }}
55 changes: 55 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}

defaults:
run:
shell: bash

name: Python ${{ matrix.python-version }} on OS ${{ matrix.os }}
steps:

- name: Acquire sources
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Setup Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Apply cache
id: poetry-cache-flag
uses: actions/cache@v3
env:
# Increase this value to reset cache if `poetry.lock` has not changed.
CACHE_NUMBER: 1
with:
path: .venv
key: poetry-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}-${{ env.CACHE_NUMBER }}

- name: Install dependencies
run: poetry install
if: steps.poetry-cache-flag.outputs.cache-hit != 'true'

- name: Test
run: poetry run poe test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/.idea

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

94 changes: 94 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
goethe
######

Create RST documents programmatically with Python

Introduction
************

Goethe gives you the opportunity to create your individual RST project in Python

1. **programmatically** - write your project as Python script in OOP style, place variables where ever you want
2. **dynamically** - render the project to dict, json or actual files and even PDF

Setup
*****

Via Pip:

.. code-block:: bash
pip install goethe
Via Github (latest):

.. code-block:: bash
pip install git+https://github.com/earthobservations/goethe
Structure
*********

Goethe uses 3 main levels of abstraction:

- Goethe - initialize an RST project with a Goethe
- FlatChapter - add a chapter based on one file at the same level as the Goethe
- DeepChapter - add a chapter based on a folder with its own index

A simple project could look like e.g.

.. code-block:: python
Goethe("myproj")
FlatChapter("overview")
DeepChapter("depper_level)
FlatChapter("overview")
DeepChapter("second_chapter")
with following file structure:
.. code-block:: python
./
index.rst
overview.rst
./deeper_level
index.rst
overview.rst
./deeper_level/second_chapter
index.rst
Features
********
- setup a RST project
- export to dict, files or html
- flat and deep chapters to build unlimited depth of documentation
- modules of RST:
- toctree
- paragraph
Backlog
*******
Examples
********
Visualized examples can be found in the ``examples`` folder.
License
*******
Distributed under the MIT License. See ``LICENSE`` for more info.
Backlog
*******
Changelog
*********
Development
===========
Empty file added examples/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions goethe/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Goethe - Create Sphinx RST documents programmatically with Python
# -*- coding: utf-8 -*-
# Copyright (C) 2022, Benjamin Gutzmann, earthobservations developers.
# Distributed under the MIT License. See LICENSE for more info.
from goethe.chapter import DeepChapter, FlatChapter
from goethe.content import _CONTENT_TYPE, _Content
from goethe.goethe import Goethe
from goethe.header import Header
from goethe.paragraph import Paragraph
from goethe.section import Section
from goethe.toctree import TocTree
Loading

0 comments on commit 1473642

Please sign in to comment.