Skip to content

Commit

Permalink
Removed sphinx and added mkdocs (#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
puehringer authored Apr 4, 2022
1 parent 1af07aa commit cea4c7c
Show file tree
Hide file tree
Showing 23 changed files with 165 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
name: API Doc generation
command: |
. ~/venv/bin/activate
make sphinx
make mkdocs
- run:
name: Build wheel
command: |
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ lint:
test:
pytest $(pkg_src)

.PHONEY: sphinx ## Generate API docs using sphinx
sphinx:
sphinx-apidoc -o docs -f ./$(pkg_src) && sphinx-build ./docs build/docs
.PHONEY: mkdocs ## Shortcut for mkdocs command
mkdocs:
mkdocs build

.PHONY: install ## Install the requirements
install:
Expand Down
2 changes: 0 additions & 2 deletions docs/.gitignore

This file was deleted.

54 changes: 54 additions & 0 deletions docs/ID-Mapping/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# ID-Mapping introduction

## What is an ID-type?

## Adding a mapping between two ID-types

In your `__init__.py` of your plugin, you can add a new mapping via the `mapping_provider` extension point:

```python
registry.append('mapping_provider', '<my_mapping_provider_id>', '<my_plugin>.my_mapping_provider')
```

The new file `<my_plugin>.my_mapping_provider.py` containing the mapping provider, i.e. a create
function returning mapping tuples (these can be dynamically generated, coming from a db, request, ...):

```python
def create():
return [
('from', 'to', lambda ids: [[f'converted_{id}'] for id in ids]),
('to', 'from', lambda ids: [[id[10:]] for id in ids]),
]
```

Each tuple is basically `(from_idtype, to_idtype, mapping_function receiving multiple ids returning multiple ids for each id)`. Generally, the first id returned by the mapping function is preferred, however all are returned by default.

!!! note

By simply defining tuples between id-types, powerful transitive mappings can be resolved by traversing the resulting graph. Visyn Core utilizing such a graph to allow for transitive mappings.

Example:
Imagine registering the tuples `IDTypeA -> IDTypeB` and `IDTypeB -> IDTypeC`. With that, the transitive connection between `ÌDTypeA -> IDTypeC` is possible by first executing `IDTypeA -> IDTypeB`, followed by `IDTypeB -> IDTypeC`.

## Mapping between two ID-types

* You can test it by showing all possible idtypes:

[http://localhost:9000/api/idtype](http://localhost:9000/api/idtype)

* Or where 'from' can be mapped to:

[http://localhost:9000/api/idtype/from](http://localhost:9000/api/idtype/from)

* Or mapping 'from' to 'to' for some ids:

[http://localhost:9000/api/idtype/from/to?q=1,2,3](http://localhost:9000/api/idtype/from/to?q=1,2,3)

* Or mapping 'to' to 'from' for some ids:

[http://localhost:9000/api/idtype/to/from?q=converted_1,converted_2,converted_3](http://localhost:9000/api/idtype/to/from?q=converted_1,converted_2,converted_3)

* Or mapping 'from' to 'to' for some ids and only wanting the first mapped id each:

[http://localhost:9000/api/idtype/from/to?q=1,2,3&mode=first](http://localhost:9000/api/idtype/from/to?q=1,2,3&mode=first
)
Empty file removed docs/_static/touch.txt
Empty file.
Empty file removed docs/_templates/touch.txt
Empty file.
29 changes: 29 additions & 0 deletions docs/commands/command-extension-point.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# `command` Extension Point

The `command` extension point supports adding custom commands which are executed within the server context, i.e. with loaded plugin registry, migrations, etc. These command override the default server startup and execute the command only.

## Register a custom command

Registering custom commands is considered legacy and will not be discussed thoroughly.

## Running a custom command

The python module `tdp_core.cmd` can be used as executable module to run any registered command. The corresponding call (executed in the same bash where the server is usually executed, i.e. docker if in dockerized environment) looks like this:

```bash
python -m tdp_core.cmd <cmd-id> <cmd-arg1> <cmd-arg2> <...>
```

More concretely, one can trigger a database upgrade using the following command:

```bash
python -m tdp_core.cmd db-migration <migration-id> upgrade head
```

And a complete downgrade using following command:

```bash
python -m tdp_core.cmd db-migration <migration-id> downgrade base
```

Please see the official alembic documentation regarding database migrations: [https://alembic.sqlalchemy.org/en/latest/api/commands.html](https://alembic.sqlalchemy.org/en/latest/api/commands.html).
2 changes: 2 additions & 0 deletions docs/commands/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO: Commands introduction

126 changes: 0 additions & 126 deletions docs/conf.py

This file was deleted.

2 changes: 2 additions & 0 deletions docs/database/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO: Databases introduction

33 changes: 33 additions & 0 deletions docs/development/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# TODO: Development Introduction

All important scripts are exposed via the Makefile. Use `make help` to show all available commands.

## Formatting

Use `make format` to reformat all corresponding files.

## Linting

Use `make lint` to check for linting issues.

## Testing

Use `make test` to run the available test-suites using pytest.

## Writing documentation

[mkdocs-material](https://squidfunk.github.io/mkdocs-material/) is used to write this documentation.

### Commands

* `make mkdocs new [dir-name]` - Create a new project.
* `make mkdocs serve` - Start the live-reloading docs server.
* `make mkdocs build` - Build the documentation site.
* `make mkdocs -h` - Print help message and exit.

### Project layout

mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.
1 change: 1 addition & 0 deletions docs/development/workspaces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO: Developer Workspace
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Welcome to Visyn Core

Visyn Core is the core of the Visyn Platform, an open-source platform for developing scalable web-based visual ananlytics platforms.
20 changes: 0 additions & 20 deletions docs/index.rst

This file was deleted.

2 changes: 2 additions & 0 deletions docs/middleware/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO: Middleware

2 changes: 2 additions & 0 deletions docs/plugins/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# TODO: Plugins and Extensions

1 change: 1 addition & 0 deletions docs/plugins/write-your-own-plugin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO: Write your own plugin
1 change: 1 addition & 0 deletions docs/security/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO: Security
1 change: 1 addition & 0 deletions docs/settings/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO: Settings
26 changes: 26 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
site_name: Visyn Core
theme:
name: material
features:
- navigation.expand
palette:
- media: "(prefers-color-scheme: light)"
scheme: default
primary: blue
toggle:
icon: material/toggle-switch-off-outline
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: blue
toggle:
icon: material/toggle-switch
name: Switch to light mode
markdown_extensions:
- admonition
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
- pymdownx.details
4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ black~=22.3.0
debugpy~=1.5.1
flake8~=4.0.1
isort~=5.10.1
mkdocs-material~=8.2.8
pep8-naming~=0.12.1
pytest-runner~=6.0.0
pytest~=7.1.1
recommonmark~=0.7.1
Sphinx~=4.4.0
recommonmark~=0.7.1
4 changes: 2 additions & 2 deletions tdp_core/security/store/base_store.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Union
from typing import Optional

from fastapi import FastAPI, Request

Expand All @@ -18,5 +18,5 @@ def load_from_request(self, request: Request) -> User:
def login(self, username: str, extra_fields={}) -> User:
return None

def logout(self, user: User) -> Union[LogoutReturnValue, None]:
def logout(self, user: User) -> Optional[LogoutReturnValue]:
pass
9 changes: 0 additions & 9 deletions tdp_core/security/store/dummy_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ def is_password(self, given):
return given_h == self.password


def from_env_var(k, v):
elems = v.split(";")
name = k[12:] # PHOVEA_USER_
salt = elems[0]
password = elems[1]
roles = elems[2:]
return DummyUser(id=name, name=name, roles=roles, password=password, salt=salt)


class DummyStore(BaseStore):
def __init__(self):
self._users = [
Expand Down

0 comments on commit cea4c7c

Please sign in to comment.