-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update documentation #238
base: main
Are you sure you want to change the base?
Update documentation #238
Changes from 7 commits
2573260
0370d06
0be8e20
26aba45
71a4edc
08d34d2
e6fad22
32e99f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,3 +121,5 @@ pom.xml.asc | |
.clj-kondo/* | ||
!.clj-kondo/config.edn | ||
*.iml | ||
/node_modules/ | ||
/package.json |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
<img src="resources/images/Xiana.png" width="242"> | ||
|
||
# Contribution | ||
|
||
- [Ticket system](#ticket-system) | ||
- [Coding standards](#coding-standards) | ||
- [Submitting a PR](#submitting-a-pr) | ||
- [Development dependencies](#development-dependencies) | ||
- [Setup](#setup) | ||
- [Deps](#deps) | ||
- [Releasing](#releasing) | ||
- [Generating API docs](#generating-api-docs) | ||
|
||
## Ticket system | ||
|
||
We're using GitHub [issues](https://github.com/Flexiana/framework/issues) for tracking and discussing ideas and | ||
requests. | ||
|
||
## Coding standards | ||
|
||
Please follow `clj-style` and `kondo` instructions. `Kibit` isn't a showstopper, but PRs are more welcomed if not | ||
breaking `kibit`. | ||
|
||
## Submitting a PR | ||
|
||
Before you are submitting a PR be sure: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Before you submit a PR be sure:" |
||
|
||
- You've updated the documentation and the [CHANGELOG](../CHANGELOG.md) | ||
- the PR has an issue in GitHub, with a good description | ||
- you have added tests | ||
- you provided an example project for a new feature | ||
- All PRs need at least two approvals | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't really belong in a list of things to check. Maybe just move it to its own paragraph after the list. |
||
- Follow [Semantic Versioning 2.0.0](https://semver.org/#semantic-versioning-200) | ||
|
||
## Development dependencies | ||
|
||
|
@@ -31,12 +58,8 @@ | |
| nilenso/honeysql-postgres | 0.2.6 | PostGreSQL | | ||
| org.postgresql/postgresql | 42.2.2 | PostGreSQL | | ||
| crypto-password/crypto-password | 0.2.1 | Security | | ||
|
||
#### Optional | ||
|
||
| Name | Version | Provide | | ||
|---------------------|---------|---------| | ||
| clj-kondo/clj-kondo | RELEASE | Tests | | ||
| clj-kondo/clj-kondo | RELEASE | Tests | | ||
| npx | RELEASE | Documentation | | ||
|
||
## Setup | ||
|
||
|
@@ -84,4 +107,38 @@ clj -M:install | |
|
||
- Be sure all examples has the same framework version as it is in `release.edn` as dependency | ||
- Execute `./example-tests.sh` script. It will install the actual version of xiana, and go through the examples folder | ||
for `check-style` and `lein test`. | ||
for `check-style` and `lein test`. | ||
|
||
## Generating API Docs | ||
|
||
This is done with using [mermaid-cli](https://github.com/mermaid-js/mermaid-cli) and a forked version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. either "with" or "using". Not both. |
||
of [Codox](https://github.com/Flexiana/codox). | ||
|
||
We're using mermaid-cli for render UML-diagrams in markdown files, see the `doc/conventions_template.md` for example. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "...mermaid-cli to render..." |
||
These files need to be added to the `/script/build-docs.sh` . For using it you need to have `npx`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "To use it you need...." |
||
|
||
Codox is forked because markdown anchors aren't converted to HTML anchors in the official release. For use, you need to | ||
|
||
```shell | ||
git clone [email protected]:Flexiana/codox.git | ||
cd codox/codox | ||
lein install | ||
``` | ||
|
||
it before generating the documentation. | ||
|
||
To generate or update the current version run the script: | ||
|
||
```shell | ||
./script/build-docs.sh | ||
``` | ||
|
||
This runs the following: | ||
|
||
```shell | ||
npx -py @mermaid-js/mermaid-cli mmdc -i doc/conventions_template.md -o doc/conventions.md | ||
clj -X:codox | ||
mv docs/new docs/{{version-number}} | ||
``` | ||
|
||
It also updates the index.html file to point to the new version. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
<img src="resources/images/Xiana.png" width="242"> | ||
|
||
# Conventions | ||
|
||
- [Overview](#overview) | ||
- [State](#state) | ||
- [Action](#action) | ||
- [Handler](#handler) | ||
- [Dependencies](#dependencies) | ||
- [Interceptors](#interceptors) | ||
- [Interceptors error handling](#interceptors-error-handling) | ||
|
||
## Overview | ||
|
||
The diagram bellow gives you an overview, how a request is processed in Xiana based applications. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "... an overview of how a request..." |
||
![diagram](./conventions-1.svg) | ||
## State | ||
|
||
A state record. It is created for each HTTP request and represents the current state of the application. It contains: | ||
State is created for each HTTP request and represents the current state of the application. It contains: | ||
|
||
- the application's dependencies | ||
- the application's dependencies and configuration | ||
- request | ||
- request-data | ||
- response | ||
|
@@ -49,11 +57,11 @@ Actions are defined in the routes vector | |
|
||
## Handler | ||
|
||
Xiana's handler does all the processing. It runs on every request and does the following. It creates the state for every | ||
request, matches the appropriate route, executes the interceptors, handles interceptor overrides, and not-found cases. | ||
Xiana's handler creates the state for every request, matches the appropriate route, executes the interceptors, handles | ||
interceptor overrides, and not-found cases. | ||
It handles websocket requests too. | ||
|
||
### Routing | ||
## Routing | ||
|
||
Routing means selecting the actions to execute depending on the request URL, and HTTP method. | ||
|
||
|
@@ -64,5 +72,20 @@ the state on state creation, and defined on application startup. | |
|
||
## Interceptors | ||
|
||
An interceptor is a pair of unary functions. Each function must recieve and return a state map. You can look at it as on an analogy to AOP's around aspect, or as on a pair of middlewares. They work mostly the same way as [pedestal](http://pedestal.io/reference/interceptors) and [sieppari](https://github.com/metosin/sieppari) interceptors. | ||
Xiana provides a set of base [interceptors](interceptors.md), for the most common use cases. | ||
An interceptor is a pair of unary functions. Each function must recieve and return a state map. You can look at it as on | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "look at it as an analogy...." |
||
an analogy to AOP's around aspect, or as on a pair of middlewares. They work mostly the same way | ||
as [pedestal](http://pedestal.io/reference/interceptors) and [sieppari](https://github.com/metosin/sieppari) | ||
interceptors. | ||
Xiana provides a set of base interceptors, for the most common use cases. | ||
|
||
This figure shows how interceptors are executed ideally: | ||
![diagram](./conventions-2.svg) | ||
## Interceptors error handling: | ||
|
||
The interceptor executor handles the exceptional states like sieppari does. If an exception happens, it tries to handle | ||
first in the same interceptor. If it has and `:error` handler, it will call it, otherwise it'll search for `:error` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "If it has an..." |
||
handlers for the beginning of the interceptor queue. When and `:error` function found, and matched with the given | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should "for" be "from"? |
||
exception, the executor calls the queue `:leave` functions in reserved order, where the handler has been found. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe "...calls the queue of |
||
|
||
This diagram shows how the error cases handled: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "..cases are handled:" |
||
![diagram](./conventions-3.svg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"...more welcome if they don't break kibit.'