Skip to content

Commit 6261219

Browse files
committed
Topiary Book: Editorial sweep (#898)
* Easy/cheap changes for consistency * Apparently links in PR descriptions don't work as expected :( * Document C/C++ toolchain dependency * Clean up relics * Topiary Book style guide * Edit wrt style guide * Small tweaks to style guide
1 parent 0608169 commit 6261219

22 files changed

+194
-93
lines changed

.github/pull_request_template.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ This is particularly important if this PR is preparing a release.
3333

3434
Checklist before merging, wherever relevant:
3535

36-
- [ ] [`CHANGELOG.md`](/CHANGELOG.md) updated
37-
- [ ] Documentation ([The Topiary Book](/docs/book), [`README.md`](/README.md), etc.) up-to-date
36+
- [ ] `CHANGELOG.md` updated
37+
- [ ] Documentation (The Topiary Book, `README.md`, etc.) up-to-date

docs/book/src/cli/configuration.md

+18-12
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ relates to [Nickel](https://nickel-lang.org/), a configuration language
55
created by Tweag. There are up to four sources where Topiary checks for
66
such a file.
77

8-
## Configuration Sources
8+
## Configuration sources
99

10-
At build time the [`languages.ncl`](./languages.ncl) in the root of the
11-
Topiary repository is embedded into Topiary. This file is parsed at
12-
runtime. The purpose of this `languages.ncl` file is to provide sane
13-
defaults for users of Topiary (both the library and the CLI binary).
10+
At build time the [`languages.ncl`](https://github.com/tweag/topiary/blob/main/topiary-config/languages.ncl)
11+
in the root of the Topiary repository is embedded into Topiary. This
12+
file is parsed at runtime. The purpose of this `languages.ncl` file is
13+
to provide sane defaults for users of Topiary (both the library and the
14+
CLI binary).
1415

1516
The next two are read by the Topiary binary at runtime and allow the
1617
user to configure Topiary to their needs. The first is intended to be
@@ -20,8 +21,8 @@ the OS:
2021
| OS | Typical Configuration Path |
2122
| :------ | :--------------------------------------------------------------- |
2223
| Unix | `/home/alice/.config/topiary/languages.ncl` |
23-
| Windows | `C:\Users\Alice\AppData\Roaming\Topiary\config\languages.ncl` |
2424
| macOS | `/Users/Alice/Library/Application Support/Topiary/languages.ncl` |
25+
| Windows | `C:\Users\Alice\AppData\Roaming\Topiary\config\languages.ncl` |
2526

2627
This file is not automatically created by Topiary.
2728

@@ -45,13 +46,10 @@ following order (highest to lowest):
4546

4647
### Configuration merging
4748

48-
<!-- TODO: See issue #861 -->
49-
5049
By default, Topiary only considers the configuration file with the
51-
[highest priority](../configuration.md). However, if
52-
the `-M` or `--merge-configuration` option is provided to the CLI, then
53-
all available configurations are merged together, as per the [Nickel
54-
specification](https://nickel-lang.org/user-manual/merging).
50+
highest priority. However, if the `-M`/`--merge-configuration` option is
51+
provided to the CLI, then all available configurations are merged
52+
together, as per the [Nickel specification](https://nickel-lang.org/user-manual/merging).
5553

5654
In which case, if one of the sources listed above attempts to define a
5755
language configuration already present in the built-in configuration, or
@@ -89,6 +87,14 @@ To override only the indentation, use the following Nickel file:
8987
}
9088
```
9189

90+
<div class="warning">
91+
92+
The merging semantics for Topiary's grammar configuration (see
93+
[below](#specifying-the-grammar)) is not yet fully defined; see issue
94+
[#861](https://github.com/tweag/topiary/issues/861).
95+
96+
</div>
97+
9298
## Configuration options
9399

94100
The configuration file contains a record of languages. That is, it

docs/book/src/cli/dialogue.md

+2-7
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,8 @@ In that case, you don't have to worry about making
2626
`TOPIARY_LANGUAGE_DIR` has been set at build time and is set at runtime
2727
as well, the runtime value takes precedence.
2828

29-
<!----------------------------------------------------------------------
30-
TODO: Move CONTRIBUTING.md into the Topiary Book
31-
32-
For a subsequent PR...
33-
----------------------------------------------------------------------->
34-
See [`CONTRIBUTING.md`](https://github.com/tweag/topiary/blob/main/CONTRIBUTING.md)
35-
for details on setting up a development environment.
29+
See [the contributor's guide](../guides/contributing.html) for details
30+
on setting up a development environment.
3631

3732
## Logging
3833

docs/book/src/cli/usage/format.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ the `--language` and, optionally, `--query` arguments, omitting any
5555
input files.
5656

5757
Valid language identifiers, as specified with `--language`, are defined
58-
as part of your Topiary configuration. Please see the
59-
[configuration](../configuration.md) section for more details.
58+
as part of your Topiary configuration. See the [configuration](../configuration.md)
59+
chapter for more details.
6060

6161
<div class="warning">
6262

docs/book/src/cli/usage/index.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ Options:
2929
```
3030
<!-- usage:end -->
3131

32-
Please see the respective section for usage documentation on each
33-
subcommand:
32+
See the respective chapter for usage documentation on each subcommand:
3433

3534
- [`format`](format.md)
3635
- [`visualise`](visualise.md)

docs/book/src/cli/usage/visualise.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ specify the `--language` and, optionally, `--query` arguments, omitting
6565
the input file. The visualisation output is written to standard out.
6666

6767
Valid language identifiers, as specified with `--language`, are defined
68-
as part of your Topiary configuration. Please see the
69-
[configuration](../configuration.md) section for more details.
68+
as part of your Topiary configuration. See the [configuration](../configuration.md)
69+
chapter for more details.

docs/book/src/getting-started/configuration.md

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
# Installation
22

33
Topiary can be installed in a few different ways. For more information
4-
on these, please see the respective section:
4+
on these, see the respective chapter:
55

66
- [Package managers](package-managers.md)
77
- [Building from source](building-from-source.md)
88
- [Using Nix](using-nix.md)
9+
10+
## Dependencies
11+
12+
The Topiary CLI will build Tree-sitter grammars on demand, optionally
13+
fetching them from a Git remote first. For this to work, your
14+
environment will need a C/C++ toolchain (i.e., compiler and linker)
15+
available. If this is available, it should "just work"; otherwise, refer
16+
to the [underlying mechanism's documentation](https://docs.rs/cc/latest/cc/#external-configuration-via-environment-variables)
17+
for configuration advice.
18+
19+
Alternatively, the [Tree-sitter CLI](https://github.com/tree-sitter/tree-sitter/blob/master/cli/README.md)
20+
can be used to build Tree-sitter grammars outside of Topiary, which can
21+
then be loaded through [configuration](../../cli/configuration.md#specifying-the-grammar)
22+
from your local filesystem.

docs/book/src/getting-started/installation/package-managers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The Topiary CLI, amongst other things, is available on
99
[crates.io](https://crates.io/crates/topiary-cli):
1010

1111
```sh
12-
cargo install -p topiary-cli
12+
cargo install topiary-cli
1313
```
1414

1515
## OPAM (OCaml Package Manager)
@@ -45,7 +45,7 @@ home.packages = with pkgs; [
4545
];
4646
```
4747

48-
### Nix Install
48+
### Nix install
4949

5050
```sh
5151
# Using flakes:

docs/book/src/getting-started/on-tree-sitter.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ define a formatting style for the language in question.
9898
<div class="warning">
9999
Topiary makes no assumption about a language's token separators. When
100100
it parses any input source into a collection of nodes, it will only
101-
apply formatting that has been explicitly defined with capture nodes, in
101+
apply formatting that has been explicitly defined with capture names, in
102102
a query file. This can result in any unspecified nodes losing their
103103
token separators (e.g., spacing) after formatting. That is, nodes can be
104104
"squashed" together, which can change (or even break) the code's

docs/book/src/guides/adding-a-new-language.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,6 @@ format C code.
200200

201201
You can now iterate on the formatting queries and the respective input
202202
and expected sample files to build your formatter, using the I/O and
203-
coverage tests to guide the process. Please also see the [following
203+
coverage tests to guide the process. Also see the [following
204204
chapter](suggested-workflow.md) on query development for more
205205
information.

docs/book/src/index.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -30,46 +30,46 @@ languages using a [simple DSL][tree-sitter:query]. This allows for the
3030
fast development of formatters, providing a [Tree-sitter
3131
grammar][tree-sitter:parsers] is defined for that language.
3232

33-
## Design Principles
33+
## Design principles
3434

3535
Topiary has been created with the following goals in mind:
3636

37-
* Use [Tree-sitter] for parsing, to avoid writing yet another grammar
37+
- Use [Tree-sitter] for parsing, to avoid writing yet another grammar
3838
for a formatter.
3939

40-
* Expect idempotency. That is, formatting of already-formatted code
40+
- Expect idempotency. That is, formatting of already-formatted code
4141
doesn't change anything.
4242

43-
* For bundled formatting styles to meet the following constraints:
43+
- For bundled formatting styles to meet the following constraints:
4444

45-
* Be compatible with attested formatting styles used for that language
45+
- Be compatible with attested formatting styles used for that language
4646
in the wild.
4747

48-
* Be faithful to the author's intent: if code has been written such
48+
- Be faithful to the author's intent: if code has been written such
4949
that it spans multiple lines, that decision is preserved.
5050

51-
* Minimise changes between commits such that diffs focus mainly on the
51+
- Minimise changes between commits such that diffs focus mainly on the
5252
code that's changed, rather than superficial artefacts. That is, a
5353
change on one line won't influence others, while the formatting
5454
won't force you to make later, cosmetic changes when you modify your
5555
code.
5656

57-
* Be well-tested and robust, so that the formatter can be trusted in
57+
- Be well-tested and robust, so that the formatter can be trusted in
5858
large projects.
5959

60-
* For end users -- i.e., not formatting style authors -- the formatter
60+
- For end users -- i.e., not formatting style authors -- the formatter
6161
should:
6262

63-
* Prescribe a formatting style that, while customisable, is uniform
63+
- Prescribe a formatting style that, while customisable, is uniform
6464
and "good enough" for their codebase.
6565

66-
* Run efficiently.
66+
- Run efficiently.
6767

68-
* Afford simple integration with other developer tools, such as
68+
- Afford simple integration with other developer tools, such as
6969
editors and language servers.
7070

7171
[gofmt]: https://pkg.go.dev/cmd/gofmt
7272
[gofmt:slides]: https://go.dev/talks/2015/gofmt-en.slide#1
7373
[tree-sitter]: https://tree-sitter.github.io/tree-sitter
74-
[tree-sitter:query]: https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries
75-
[tree-sitter:parsers]: https://tree-sitter.github.io/tree-sitter/#available-parsers
74+
[tree-sitter:query]: https://tree-sitter.github.io/tree-sitter/using-parsers/queries/index.html
75+
[tree-sitter:parsers]: https://github.com/tree-sitter/tree-sitter/wiki/List-of-parsers

docs/book/src/installation/index.md

-1
This file was deleted.

docs/book/src/playground/web.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ development and has diverged from newer releases of Topiary. The web
77
playground is kept online, for demonstrative purposes, but newer
88
features have **not been implemented**.
99

10-
Please see GitHub to [assess the divergence](https://github.com/tweag/topiary/compare/playground...main).
10+
See GitHub to [assess the divergence](https://github.com/tweag/topiary/compare/playground...main).
1111

1212
</div>
1313

docs/book/src/reference/capture-names/indentation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ strings (defined in the [language configuration](../../cli/configuration.md#inde
99
## `@append_indent_start` / `@prepend_indent_start`
1010

1111
The matched nodes will trigger indentation before (or, respectively,
12-
after) them. This will only apply to lines following, until an
12+
after) them. This will only apply to the lines following, until an
1313
indentation end is signalled. If indentation is started and ended on the
1414
same line, nothing will happen. This is useful, because we get the
1515
correct behaviour whether a node is formatted as single-line or

docs/book/src/reference/capture-names/index.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ recognised by Topiary to drive formatting.
1515

1616
> **Note**\
1717
> This example is derived from the [Topiary announcement blog
18-
> post][tweag:topiary-announcement]. Please see the post for additional
19-
> detail.
18+
> post][tweag:topiary-announcement]; see the post for additional detail.
2019
2120
```scheme
2221
(

docs/book/src/reference/capture-names/scopes.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ These predicates allow the query to trigger only if the associated custom scope
122122
containing the matched nodes are is single-line (resp. multi-line).
123123

124124
> **Note**\
125-
> There are non-scoped equivalents to these predicates; please see
126-
> [vertical spacing](vertical-spacing.md#testing-context-with-predicates)
127-
> for details.
125+
> There are non-scoped equivalents to these predicates; see [vertical
126+
> spacing](vertical-spacing.md#testing-context-with-predicates) for
127+
> details.
128128
129129
##### Example
130130

docs/book/src/reference/capture-names/vertical-spacing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ These predicates allow the query to trigger only if the matched nodes
234234
are in a single-line (or, respectively, multi-line) context.
235235

236236
> **Note**\
237-
> There are scoped equivalents to these predicates; please see
237+
> There are scoped equivalents to these predicates; see
238238
> [scopes](scopes.md#testing-context-with-predicates) for details.
239239
240240
##### Example

docs/book/src/reference/language-support.md

+14-19
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
# Language support
22

3-
<!-- Update this section as necessary on new developments/releases -->
4-
53
<!----------------------------------------------------------------------
6-
TODO Lay out expectations for contributed languages and what constitutes
7-
a language being "experimental" (or otherwise). See issue #876
8-
9-
(I've made it a bit clearer here, but it could be much better...)
4+
Update these sections as necessary on new developments/releases
105
----------------------------------------------------------------------->
116

127
Topiary ships with formatting support for a number of languages. The
@@ -30,23 +25,23 @@ stated design goals. They are exposed, in Topiary, through the
3025
`--language` command line flag, or language detection (based on file
3126
extension).
3227

33-
* [Bash]
34-
* [JSON]
35-
* [Nickel]
36-
* [OCaml] (both implementations and interfaces)
37-
* [OCamllex]
38-
* [TOML]
39-
* [Tree Sitter Queries][tree-sitter-query]
28+
- [Bash]
29+
- [JSON]
30+
- [Nickel]
31+
- [OCaml] (both implementations and interfaces)
32+
- [OCamllex]
33+
- [TOML]
34+
- [Tree Sitter Queries][tree-sitter-query]
4035

4136
## Contributed
4237

4338
These languages' formatting styles have been generously provided by
44-
external contributors. They are built in, by default, so are exposed in
45-
the same way as supported languages.
39+
external contributors. They are built in, by default -- unless marked as
40+
experimental -- so are exposed in the same way as supported languages.
4641

47-
* [CSS], by [Eric Lavigne](https://github.com/lavigneer)
48-
* [OpenSCAD], by [Mikhail Katychev](https://github.com/mkatychev)
49-
* [SDML], by [Simon Johnston](https://github.com/johnstonskj)
42+
- [CSS], by [Eric Lavigne](https://github.com/lavigneer)
43+
- [OpenSCAD], by [Mikhail Katychev](https://github.com/mkatychev)
44+
- [SDML], by [Simon Johnston](https://github.com/johnstonskj)
5045

5146
## Experimental
5247

@@ -57,7 +52,7 @@ feature flag (either `experimental`, for all of them, or by their
5752
individual name). Once included, they can be accessed in Topiary in the
5853
usual way.
5954

60-
* [Rust]
55+
- [Rust]
6156

6257
<!-- Links -->
6358
[bash]: https://www.gnu.org/software/bash

docs/book/src/reference/library.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ documentation can be found on [docs.rs][topiary-docs]. Of main interest
55
is the `formatter` function that performs the actual formatting. The
66
example in the documentation of that function is kept up to date.
77

8-
For a more complete example, please see the [client-app example in the
9-
Topiary repository][client-app].
8+
For a more complete example, see the [client-app example in the Topiary
9+
repository][client-app].
1010

1111
[client-app]: https://github.com/tweag/topiary/tree/main/examples/client-app
1212
[topiary-crate]: https://crates.io/crates/topiary-core

0 commit comments

Comments
 (0)