Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
emdoyle committed Oct 4, 2024
1 parent f3fc87f commit e59a928
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/usage/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ as modules with `Ctrl + a`.
You can also mark your Python [source roots](configuration#source-roots) by pressing `s`.
This allows Tach to understand module paths and correctly identify first-party imports.
You can mark modules as [utilities](configuration#modules) by pressing `u`. This is appropriate for modules like `utils/`, which can be freely used by the rest of the code.
To save your modules, use `Ctrl + s`. Otherwise, to exit without saving, use `Ctrl + c`.
Any time you make changes with `tach mod`, run [`tach sync`](commands#tach-sync)
Expand Down
10 changes: 8 additions & 2 deletions docs/usage/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ path = "tach.__main__"
depends_on = [{ path = "tach.start" }]
strict = true

[[modules]]
path = "tach.errors"
depends_on = []
strict = true
utility = true

[[modules]]
path = "tach.parsing"
depends_on = [{ path = "tach" }, { path = "tach.filesystem" }]
Expand All @@ -58,7 +64,6 @@ strict = true
[[modules]]
path = "tach.check"
depends_on = [
{ path = "tach.errors" },
{ path = "tach.extension" },
{ path = "tach.filesystem" },
{ path = "tach.parsing" },
Expand All @@ -81,7 +86,8 @@ Each module listed under the `modules` key above can accept the following attrib
- `path`: the Python import path to the module (e.g. `a.b` for `<root>/a/b.py`)
- `depends_on`: a list of the other modules which this module can import from (default: `[]`)
- `visibility`: a list of other modules which can import from this module (default: `['*']`)
- `strict`: enables [strict mode](strict-mode) for the module
- `strict`: enables [strict mode](strict-mode) for the module (boolean)
- `utility`: marks this module as a **Utility**, meaning all other modules may import from it without declaring an explicit dependency (boolean)

<Note>
Tach also supports [deprecating individual dependencies](../usage/deprecate).
Expand Down
16 changes: 16 additions & 0 deletions docs/usage/faq.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ To prevent any external usage of a given module, you can set `visibility: []` fo

[See more information on configuration here.](./configuration)

### How can I declare modules which are freely usable by the rest of the code?

This is typically done for modules like `utils/`, `errors/` or `lib/`, which contain relatively isolated code which can be used throughout a project.

Tach allows marking these modules as **Utilities**, which means they can be used without being listed as an explicit dependency.

<Note>
Marking a module with `utility: true` is different from `visibility: ['*']`.
Even when a module has public visibility, other modules must declare an
explicit dependency to use it (in fact, modules are publicly visible by
default). In contrast, a utility module does not require its dependents to
list an explicit dependency.
</Note>

[See more information on configuration here.](./configuration)

### Are conditional imports checked?

Tach will check all imports in your source files, including those which are called conditionally.
Expand Down

0 comments on commit e59a928

Please sign in to comment.