Skip to content

Commit bd2022e

Browse files
committed
Format and fix dead links in how-it-works doc
1 parent 5403a65 commit bd2022e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/theme-graph/docs/how-it-works.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
## Table of contents
44

55
1. [What it looks like](#what-it-looks-like)
6-
1. [Concepts overview](#concepts-overview)
7-
2. [Algorithm overview](#algorithm-overview)
6+
1. [Concepts overview](#concepts)
7+
1. [Algorithm overview](#algorithm-overview)
88

99
## What it looks like
1010

@@ -18,42 +18,47 @@ It's a web of modules and links between them.
1818

1919
A **Graph** is a set of Nodes and Edges.
2020

21-
A **Theme Graph** is a set of *Modules* (nodes) and *References* (edges) defined by an array of *Entry Points*. It has these properties:
21+
A **Theme Graph** is a set of _Modules_ (nodes) and _References_ (edges) defined by an array of _Entry Points_. It has these properties:
22+
2223
- `rootUri` - root of the theme, e.g. `file:/path/to/theme`
2324
- `entryPoints` - array of modules that define the theme (all templates and sections)
2425
- `modules` - all the modules in the theme indexed by URI
2526

2627
A **Module** is an object that represents a theme file. It has these properties:
28+
2729
- `uri` - module identifier, e.g. `file:/path/to/theme/snippets/file.liquid`
2830
- `type` - e.g. `liquid`, `json`, `javascript`, `css`.
2931
- `kind` - e.g. `block`, `section`, `snippet`, `template`, etc.
30-
- `references` - array of *References* that point to this module.
31-
- `dependencies` - array of *References* that this module depends on.
32+
- `references` - array of _References_ that point to this module.
33+
- `dependencies` - array of _References_ that this module depends on.
3234

3335
A **Reference** is an object that defines a link between two modules. It has these properties:
36+
3437
- `source` - a `uri` and `range` that defines which module depends on an other and _where_ in the source file,
3538
- `target` - a `uri` and `range` that defines which module is being dependended on and optionally what is being depended on in that file,
3639
- `type` - one of the following:
3740
- `direct` - the file can't exist without the other, e.g. `{% render 'child' %}`
3841
- `preset` - the file has a preset that depends on an other file, e.g. a section that has a preset that includes `group` and `text` blocks.
3942
- `indirect` - the file loosely depends on the other, but not explicilty. e.g. when a file accepts all public theme blocks (`"type": "@theme"`))
4043

41-
4244
## Algorithm overview
4345

4446
To build the graph, we _traverse_ each module in the set of entry points.
4547

4648
When we _traverse_ a module, we do the following:
49+
4750
- if the module was already visited, we return early, else
4851
- we extract dependencies from the module's AST, then
4952
- we _bind_ the module with its dependent modules, then
5053
- we _traverse_ the dependent modules (it's a recursive algorithm).
5154

5255
When we _bind_ a parent module with a child module, we do the following:
56+
5357
- we add the child module to the parent's dependencies,
5458
- we add the parent module to the child's references
5559

5660
In pseudo code, it looks a bit like this:
61+
5762
```
5863
INPUT rootUri
5964
OUTPUT graph

0 commit comments

Comments
 (0)