Skip to content

Commit 864b1c8

Browse files
committed
Add info about using Foliant with Poetry.
1 parent ec36420 commit 864b1c8

3 files changed

Lines changed: 79 additions & 6 deletions

File tree

src/installation.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ tags:
66

77
# Installation
88

9-
Installation of Foliant is split into three stages: installing Python with your system’s package manager, installing Foliant with pip, and optionally installing Pandoc and TeXLive bundle. Below you’ll find the instructions for three popular platforms: macOS, Windows, and Ubuntu.
9+
Installation of Foliant is split into three stages: installing Python with your system’s package manager, installing Foliant with pip or Poetry, and optionally installing Pandoc and TeXLive bundle. Below you’ll find the instructions for three popular platforms: macOS, Windows, and Ubuntu.
1010

1111
Alternatively, you can avoid installing Foliant and its dependencies on your system by using <link title="Docker">Docker and Docker Compose</link>.
1212

@@ -80,6 +80,25 @@ Alternatively, you can avoid installing Foliant and its dependencies on your sys
8080
$ pip3 install foliantcontrib.pandoc
8181

8282

83+
## Poetry
84+
85+
If you prefer to manage Foliant and its extensions as dependencies of your documentation project, you can use [Poetry](https://python-poetry.org/).
86+
87+
1. Install [Python](https://www.python.org/) and [Poetry](https://python-poetry.org/docs/#installation) globally on your system.
88+
89+
2. Initialize a new Poetry project in your documentation directory:
90+
91+
$ poetry init
92+
93+
3. Add Foliant and the necessary extensions as dependencies:
94+
95+
$ poetry add foliant foliantcontrib.init
96+
97+
4. To build your project, use `poetry run`:
98+
99+
$ poetry run foliant make site
100+
101+
83102
## Docker
84103

85104
There is a selection of Docker images for Foliant in the [Docker hub](https://hub.docker.com/r/foliant/foliant):

src/quickstart.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ If you don't have Foliant installed, please follow <link src="installation.md">t
1313
$ foliant init
1414
```
1515

16+
Or with Poetry
17+
18+
```bash
19+
$ poetry run foliant init
20+
```
21+
1622
Or with Docker
1723

1824
```bash
@@ -39,6 +45,12 @@ pip3 install foliantcontrib.mkdocs
3945
$ foliant make site
4046
```
4147

48+
Or with Poetry
49+
50+
```bash
51+
$ poetry run foliant make site
52+
```
53+
4254
Or with Docker
4355

4456
```bash

src/tutorials/first_project.md

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ tags:
77

88
In this tutorial, you’ll learn how to use Foliant to build websites and pdf documents from a single Markdown source. You’ll also learn how to use Foliant preprocessors.
99

10-
> It is recommended to <link src="docker.md">run Foliant through Docker</link> to get consistent results on different machines, but it's also perfectly fine to run it natively (e.g. as a pure CLI tool without virtualization). In this tutorial, we will show the example commands for both native way (these will go first) and the Docker way (these will follow).
10+
> It is recommended to <link src="docker.md">run Foliant through Docker</link> to get consistent results on different machines, but it's also perfectly fine to run it natively (e.g. as a pure CLI tool without virtualization) or using **Poetry** for dependency management. In this tutorial, we will show the example commands for the native way, the Poetry way, and the Docker way.
1111
1212

1313
## Create New Project
@@ -20,11 +20,18 @@ To use it, run `foliant init` command
2020

2121
```bash
2222
$ foliant init
23+
```
24+
25+
Or, with Poetry
26+
27+
```bash
28+
$ poetry run foliant init
29+
```
30+
2331
Enter the project name: Hello Foliant
2432
Generating Foliant project
2533
─────────────────────
2634
Project "Hello Foliant" created in hello-foliant
27-
```
2835

2936
To do the same with Docker, run
3037

@@ -72,19 +79,32 @@ Let’s start with **MkDocs** backend. First, install it using the following com
7279
pip3 install foliantcontrib.mkdocs
7380
```
7481

82+
Or with Poetry
83+
84+
```bash
85+
poetry add foliantcontrib.mkdocs
86+
```
87+
7588
Docker users would normally need to add this package to the `requirements.txt` file instead, but mkdocs is already there by default if you used `init` to generate project structure.
7689

7790
To build a site, in the project directory, run
7891

7992
```bash
8093
$ foliant make site
94+
```
95+
96+
Or with Poetry
97+
98+
```bash
99+
$ poetry run foliant make site
100+
```
101+
81102
Parsing config... Done
82103
Applying preprocessor mkdocs... Done
83104
Applying preprocessor _unescape... Done
84105
Making site with MkDocs... Done
85106
────────────────────
86107
Result: Hello_Foliant-2020-05-25.mkdocs
87-
```
88108

89109
Or, with Docker Compose
90110

@@ -118,13 +138,22 @@ Then, in the project directory, run
118138

119139
```bash
120140
$ foliant make pdf
141+
```
142+
143+
Or with Poetry
144+
145+
```bash
146+
$ poetry run foliant make pdf
147+
```
148+
121149
Parsing config... Done
122150
Applying preprocessor flatten... Done
123151
Applying preprocessor _unescape... Done
124152
Making pdf with Pandoc... Done
125153
────────────────────
126154
Result: Hello_Foliant-2020-05-25.pdf
127-
```
155+
156+
To build pdf in Docker container
128157

129158
To build pdf in Docker container, first uncomment `foliant/foliant:pandoc` in your project’s `Dockerfile`
130159

@@ -199,6 +228,14 @@ The native command
199228

200229
```bash
201230
foliant make pdf && foliant make site
231+
```
232+
233+
Or with Poetry
234+
235+
```bash
236+
poetry run foliant make pdf && poetry run foliant make site
237+
```
238+
202239
Parsing config... Done
203240
Applying preprocessor flatten... Done
204241
Applying preprocessor _unescape... Done
@@ -212,7 +249,6 @@ Applying preprocessor _unescape... Done
212249
Making site with MkDocs... Done
213250
────────────────────
214251
Result: Hello_Foliant-2020-05-25.mkdocs
215-
```
216252

217253
The command for Docker
218254

@@ -263,6 +299,12 @@ First, we need to install the blockdiag preprocessor
263299
$ pip3 install foliantcontrib.blockdiag
264300
```
265301

302+
Or with Poetry
303+
304+
```bash
305+
$ poetry add foliantcontrib.blockdiag
306+
```
307+
266308
Or, if you are building with docker, add `foliantcontrib.blockdiag` to requirements.txt and rebuild the image with `docker-compose build` command.
267309

268310
Next, we need to switch on the <link src="!path src/preprocessors/blockdiag.md" title="Blockdiag">`blockdiag`</link> preprocessor in project config. Open `foliant.yml` and add the following lines

0 commit comments

Comments
 (0)