Skip to content

Commit c24269f

Browse files
committed
📝 Add first version of docs
1 parent 64d1a5f commit c24269f

File tree

8 files changed

+1477
-0
lines changed

8 files changed

+1477
-0
lines changed

docs/alternatives.md

Lines changed: 417 additions & 0 deletions
Large diffs are not rendered by default.

docs/contributing.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
First, you might want to see the basic ways to <a href="https://typer.tiangolo.com/help-typer/" target="_blank">help Typer and get help</a>.
2+
3+
Coming soon...
4+
5+
<!-- ## Developing
6+
7+
If you already cloned the repository and you know that you need to deep dive in the code, here are some guidelines to set up your environment.
8+
9+
10+
### Pipenv
11+
12+
If you are using <a href="https://pipenv.readthedocs.io/en/latest/" target="_blank">Pipenv</a>, you can create a virtual environment and install the packages with:
13+
14+
```bash
15+
pipenv install --dev
16+
```
17+
18+
Then you can activate that virtual environment with:
19+
20+
```bash
21+
pipenv shell
22+
```
23+
24+
25+
### No Pipenv
26+
27+
If you are not using Pipenv, you can create a virtual environment with your preferred tool, and install the packages listed in the file `Pipfile`.
28+
29+
30+
### Flit
31+
32+
**FastAPI** uses <a href="https://flit.readthedocs.io/en/latest/index.html" target="_blank">Flit</a> to build, package and publish the project.
33+
34+
If you installed the development dependencies with one of the methods above, you already have the `flit` command.
35+
36+
To install your local version of FastAPI as a package in your local environment, run:
37+
38+
```bash
39+
flit install --symlink
40+
```
41+
42+
It will install your local FastAPI in your local environment.
43+
44+
45+
#### Using your local FastAPI
46+
47+
If you create a Python file that imports and uses FastAPI, and run it with the Python from your local environment, it will use your local FastAPI source code.
48+
49+
And if you update that local FastAPI source code, as it is installed with `--symlink`, when you run that Python file again, it will use the fresh version of FastAPI you just edited.
50+
51+
That way, you don't have to "install" your local version to be able to test every change.
52+
53+
54+
### Format
55+
56+
There is a script that you can run that will format and clean all your code:
57+
58+
```bash
59+
bash scripts/lint.sh
60+
```
61+
62+
It will also auto-sort all your imports.
63+
64+
For it to sort them correctly, you need to have FastAPI installed locally in your environment, with the command in the section above:
65+
66+
```bash
67+
flit install --symlink
68+
```
69+
70+
71+
### Docs
72+
73+
The documentation uses <a href="https://www.mkdocs.org/" target="_blank">MkDocs</a>.
74+
75+
All the documentation is in Markdown format in the directory `./docs`.
76+
77+
Many of the tutorials have blocks of code.
78+
79+
In most of the cases, these blocks of code are actual complete applications that can be run as is.
80+
81+
In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs/src/` directory.
82+
83+
And those Python files are included/injected in the documentation when generating the site.
84+
85+
86+
#### Docs for tests
87+
88+
Most of the tests actually run against the example source files in the documentation.
89+
90+
This helps making sure that:
91+
92+
* The documentation is up to date.
93+
* The documentation examples can be run as is.
94+
* Most of the features are covered by the documentation, ensured by the coverage tests.
95+
96+
During local development, there is a script that builds the site and checks for any changes, live-reloading:
97+
98+
```bash
99+
bash scripts/docs-live.sh
100+
```
101+
102+
It will serve the documentation on `http://0.0.0.0:8008`.
103+
104+
That way, you can edit the documentation/source files and see the changes live.
105+
106+
#### Apps and docs at the same time
107+
108+
And if you run the examples with, e.g.:
109+
110+
```bash
111+
uvicorn tutorial001:app --reload
112+
```
113+
114+
as Uvicorn by default will use the port `8000`, the documentation on port `8008` won't clash.
115+
116+
117+
### Tests
118+
119+
There is a script that you can run locally to test all the code and generate coverage reports in HTML:
120+
121+
```bash
122+
bash scripts/test-cov-html.sh
123+
```
124+
125+
This command generates a directory `./htmlcov/`, if you open the file `./htmlcov/index.html` in your browser, you can explore interactively the regions of code that are covered by the tests, and notice if there is any region missing. -->

docs/features.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
## Design based on **FastAPI**
2+
3+
**Typer** is the little sibling of <a href="https://fastapi.tiangolo.com" target="_blank">FastAPI</a>.
4+
5+
It follows the same design and ideas. If you know FastAPI, you already know **Typer**... more or less.
6+
7+
## Just Modern Python
8+
9+
It's all based on standard **Python 3.6 type** declarations. No new syntax to learn. Just standard modern Python.
10+
11+
If you need a 2 minute refresher of how to use Python types (even if you don't use FastAPI or Typer), check the FastAPI tutorial section: <a href="https://fastapi.tiangolo.com/python-types/" target="_blank">Python types intro</a>.
12+
13+
You will also see a 20 seconds refresher on the section [Tutorial - User Guide: First Steps](tutorial/first-steps.md).
14+
15+
## Editor support
16+
17+
**Typer** was designed to be easy and intuitive to use, to ensure the best development experience. With autocompletion everywhere.
18+
19+
You will rarely need to come back to the docs.
20+
21+
Here's how your editor might help you:
22+
23+
* in <a href="https://code.visualstudio.com/" target="_blank">Visual Studio Code</a>:
24+
25+
![editor support](img/vscode-completion.png)
26+
27+
* in <a href="https://www.jetbrains.com/pycharm/" target="_blank">PyCharm</a>:
28+
29+
![editor support](img/pycharm-completion.png)
30+
31+
You will get completion for everything. That's something no other CLI library provides right now.
32+
33+
No more guessing what type was that variable, if it could be `None`, etc.
34+
35+
### Short
36+
37+
It has sensible **defaults** for everything, with optional configurations everywhere. All the parameters can be fine-tuned to do what you need, customize the help, callbacks per parameter, make them required or not, etc.
38+
39+
But by default, it all **"just works"**.
40+
41+
## User friendly CLI apps
42+
43+
The resulting CLI apps created with **Typer** have the nice features of many "pro" command line programs you probably already love.
44+
45+
* Automatic help commands and options.
46+
* Automatic command and sub-command structure handling (you will see more about sub-commands in the Tutorial - User Guide).
47+
* Automatic autocompletion for the CLI app in all operating systems, in all the shells (Bash, Zsh, Fish, PowerShell), so that the final user of your app can just hit <kbd>TAB</kbd> and get the options of sub-commands. *
48+
49+
!!! note * Autocompletion
50+
For the autocompletion to work on all shells you also need to add the dependency `click-completion`.
51+
52+
Just that. And **Typer** does the rest.
53+
54+
If **Typer** detects `click-completion` installed, it will automatically create a command to install completion for the user's shell.
55+
56+
Then you can tell the user to run that command and the rest will just work.
57+
58+
## The power of Click
59+
60+
<a href="https://click.palletsprojects.com" target="_blank">Click</a> is one of the most popular tools for building CLIs in Python.
61+
62+
**Typer** is based on it, so you get all its benefits, plug-ins, robustness, etc.
63+
64+
But you can write simpler code with the benefits of modern Python.
65+
66+
<!--
67+
68+
TODO
69+
70+
### Tested
71+
72+
* 100% <abbr title="The amount of code that is automatically tested">test coverage</abbr>.
73+
* 100% <abbr title="Python type annotations, with this your editor and external tools can give you better support">type annotated</abbr> code base.
74+
* Used in production applications. -->

docs/help-typer.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
Are you liking **Typer**?
2+
3+
Would you like to help Typer, other users, and the author?
4+
5+
Or would you like to get help with **Typer**?
6+
7+
There are very simple ways to help (several involve just one or two clicks).
8+
9+
And there are several ways to get help too.
10+
11+
## Star **Typer** in GitHub
12+
13+
You can "star" Typer in GitHub (clicking the star button at the top right): <a href="https://github.com/tiangolo/typer" target="_blank">https://github.com/tiangolo/typer</a>.
14+
15+
By adding a star, other users will be able to find it more easily and see that it has been already useful for others.
16+
17+
## Watch the GitHub repository for releases
18+
19+
You can "watch" Typer in GitHub (clicking the "watch" button at the top right): <a href="https://github.com/tiangolo/typer" target="_blank">https://github.com/tiangolo/typer</a>.
20+
21+
There you can select "Releases only".
22+
23+
Doing it, you will receive notifications (in your email) whenever there's a new release (a new version) of **Typer** with bug fixes and new features.
24+
25+
## Connect with the author
26+
27+
You can connect with <a href="https://tiangolo.com" target="_blank">me (Sebastián Ramírez / `tiangolo`)</a>, the author.
28+
29+
You can:
30+
31+
* <a href="https://github.com/tiangolo" target="_blank">Follow me on **GitHub**</a>.
32+
* See other Open Source projects I have created that could help you.
33+
* Follow me to see when I create a new Open Source project.
34+
* <a href="https://twitter.com/tiangolo" target="_blank">Follow me on **Twitter**</a>.
35+
* Tell me how you use Typer (I love to hear that).
36+
* Ask questions.
37+
* <a href="https://www.linkedin.com/in/tiangolo/" target="_blank">Connect with me on **Linkedin**</a>.
38+
* Talk to me.
39+
* Endorse me or recommend me :)
40+
* Read what I write (or follow me):
41+
* Read other ideas, articles and tools I have created.
42+
* Follow me to see when I publish something new.
43+
* On <a href="https://dev.to/tiangolo" target="_blank">**Dev.to**</a>.
44+
* On <a href="https://medium.com/@tiangolo" target="_blank">**Medium**</a>.
45+
46+
## Tweet about **Typer**
47+
48+
<a href="http://twitter.com/home/?status=I'm loving Typer because... https://github.com/tiangolo/typer cc @tiangolo" target="_blank">Tweet about **Typer**</a> and let me and others know why you like it.
49+
50+
## Let me know how are you using **Typer**
51+
52+
I love to hear about how **Typer** is being used, what have you liked in it, in which project/company you are using it, etc.
53+
54+
You can let me know:
55+
56+
* <a href="http://twitter.com/home/?status=Hey @tiangolo, I'm using Typer at..." target="_blank">On **Twitter**</a>.
57+
* <a href="https://www.linkedin.com/in/tiangolo/" target="_blank">On **Linkedin**</a>.
58+
* <a href="https://dev.to/tiangolo" target="_blank">On **Dev.to**</a>.
59+
* <a href="https://medium.com/@tiangolo" target="_blank">On **Medium**</a>.
60+
61+
## Help others with issues in GitHub
62+
63+
You can see <a href="https://github.com/tiangolo/typer/issues" target="_blank">existing issues</a> and try and help others.
64+
65+
## Watch the GitHub repository
66+
67+
You can "watch" Typer in GitHub (clicking the "watch" button at the top right): <a href="https://github.com/tiangolo/typer" target="_blank">https://github.com/tiangolo/typer</a>.
68+
69+
If you select "Watching" instead of "Releases only", you will receive notifications when someone creates a new issue.
70+
71+
Then you can try and help them solving those issues.
72+
73+
## Create issues
74+
75+
You can <a href="https://github.com/tiangolo/typer/issues/new/choose" target="_blank">create a new issue</a> in the GitHub repository, for example to:
76+
77+
* Report a bug/issue.
78+
* Suggest a new feature.
79+
* Ask a question.
80+
81+
## Create a Pull Request
82+
83+
You can <a href="https://github.com/tiangolo/typer" target="_blank">create a Pull Request</a>, for example:
84+
85+
* To fix a typo you found on the documentation.
86+
* To propose new documentation sections.
87+
* To fix an existing issue/bug.
88+
* To add a new feature.
89+
90+
---
91+
92+
Thanks!

0 commit comments

Comments
 (0)