authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-04-17 21:47:42 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-04-17 21:47:42 -07:00
logb3017a7cdce9cb7d00623435d8f692d1fa128b28
treeb471970c2d6be0170ccd2b23b37a3c051b3d81ad
parent1536392219e0c818ba2ff6d77a3f3bf7f4ad0027

docs/tutorial.md- use word wrap instead of multiple lines


1 files changed, 11 insertions(+), 30 deletions(-)

docs/tutorial.md+11-30
......@@ -20,8 +20,7 @@ The wizard will also ask if you'd like it setup any additional metadata files su
2020---
2121## Understanding `zigmod.yml`
2222
23Running [`zigmod init`](./commands/init.md) will ask if You want to create an application or a
24library. Based on You answer the resulting `zigmod.yml` file have two types.
23Running [`zigmod init`](./commands/init.md) will ask if You want to create an application or a library. Based on You answer the resulting `zigmod.yml` file have two types.
2524
2625### `zigmod.yml` for an application (`id` is omitted)
2726
......@@ -46,23 +45,15 @@ dependencies:
4645 - src: git https://github.com/jecolon/ziglyph
4746```
4847
49Here I assume that You initialized Your project with `zig init-exe` or
50`zig init-lib`, so Your `build.zig` the `addExecutable()` or
51`addStaticLibrary()` call points to `src/main.zig`.
48Here I assume that You initialized Your project with `zig init-exe` or `zig init-lib`, so Your `build.zig` the `addExecutable()` or `addStaticLibrary()` call points to `src/main.zig`.
5249
53In this case You can `@import("ziglyph")` in `src/lib.zig`, but not in
54`src/main.zig`. However You can `@import("my-package")` in `src/main.zig`.
50In this case You can `@import("ziglyph")` in `src/lib.zig`, but not in `src/main.zig`. However You can `@import("my-package")` in `src/main.zig`.
5551
56Please note, that using `zig init-exe` or `zig init-lib` for creating a project
57does not mean that You have to use `zigmod init` in application or library mode.
58Creating a `zigmod.yml` file with proper `name` and `main` only makes Your package
59importable by other projects. This is usually not needed with applications, but
60quite useful in case of libraries; hence the name.
52Please note, that using `zig init-exe` or `zig init-lib` for creating a project does not mean that You have to use `zigmod init` in application or library mode. Creating a `zigmod.yml` file with proper `name` and `main` only makes Your package importable by other projects. This is usually not needed with applications, but quite useful in case of libraries; hence the name.
6153
6254### Zig and Zigmod package handling explained
6355
64Zig packages can only `@import` **direct** children. The include tree is
65something like this:
56Zig packages can only `@import` **direct** children. The include tree is something like this:
6657
6758```
6859root
......@@ -73,9 +64,7 @@ root
7364 E
7465```
7566
76`root` can `@import` `A`, `B` and `D`, but `E` can be imported only from `D`.
77`B` can not import anything.
78(Everybody can import relative files, this limitation is only for packages.)
67`root` can `@import` `A`, `B` and `D`, but `E` can be imported only from `D`. `B` can not import anything. (Everybody can import relative files, this limitation is only for packages.)
7968
8069In library `zigmod.yml` example the tree looks like this:
8170
......@@ -85,20 +74,13 @@ root (src/main.zig)
8574 ziglyph (separate package)
8675```
8776
88`root` is always set in `build.zig` using `addExecutable()` or
89`addStaticLibrary()` calls.
77`root` is always set in `build.zig` using `addExecutable()` or `addStaticLibrary()` calls.
9078
91It is very important to understand, that `my-package` is _below_ `root`, as
92`name/main` in `zigmod.yml` will create a separate package (it will not be chained to
93`root`).
79It is very important to understand, that `my-package` is _below_ `root`, as `name/main` in `zigmod.yml` will create a separate package (it will not be chained to `root`).
9480
95If You want to use the dependencies from `root`, then make sure that Your
96`zigmod.yml` does _not_ contain a `main` line **and** use `root_dependencies`
97instead of `dependencies`. This is what `zigmod init` does in application mode.
81If You want to use the dependencies from `root`, then make sure that Your `zigmod.yml` does _not_ contain a `main` line **and** use `root_dependencies` instead of `dependencies`. This is what `zigmod init` does in application mode.
9882
99On the other hand using `root_dependencies` and `dependencies` is not mutually
100exclusive, You can take advantage of using both, like zigmod does. Using
101`dependencies` requires a proper `main` field in Your `zigmod.yml`.
83On the other hand using `root_dependencies` and `dependencies` is not mutually exclusive, You can take advantage of using both, like zigmod does. Using `dependencies` requires a proper `main` field in Your `zigmod.yml`.
10284
10385## Running `zigmod fetch`
10486This command will inspect your `zigmod.yml` and download any new dependencies as well as pulling updates for any ones already download. It will recursively do this for your entire tree until it is full constructed which will culminate in the generation of two output files: `deps.zig` and `zigmod.lock`.
......@@ -129,8 +111,7 @@ Add `--no-update` if you do want it to fetch remote updates and only regenerate
129111 exe.install();
130112```
131113
132> Note: If You would like to use the external dependencies in tests, do not
133forget to add `deps.addAllTo(main_tests)` after the `addTest()` call.
114> Note: If You would like to use the external dependencies in tests, do not forget to add `deps.addAllTo(main_tests)` after the `addTest()` call.
134115
135116---
136117## Adding a dependency