Skip to content

Commit f993df5

Browse files
s-z-zonsi
authored andcommitted
Fix paragraph position error
It seems the paragraph about NodeArgsTransformer was inserted in the wrong place. After “Here are a few more patterns that AroundNode enables.”, the following two subparagraphs should describe AroundNode-related content, same as before. The advanced features of NodeArgsTransformer should not interrupt that section. I’ve moved it accordingly, though please double-check that this new position makes sense.
1 parent 56cb393 commit f993df5

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/index.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,20 +1808,6 @@ Lastly, you can pass `AroundNode` to the call to `RunSpecs` that launches the Gi
18081808

18091809
Here are a few more patterns that `AroundNode` enables.
18101810

1811-
### Advanced: Transforming Node Arguments during Tree Construction
1812-
1813-
Ginkgo suites maintained by large communities (👋 Kubernetes) tend to adopt conventions to organize specs with labels and specific decorators. Enforcing these conventions is challenging but can be automated to some degree by inferring developer intent and transforming node arguments, during the Tree Construction phase, to add the relevant Ginkgo decorators.
1814-
1815-
This is done by registering a `NodeArgsTransformer` via `AddTreeConstructionNodeArgsTransformer`. The `NodeArgsTransformer` has signature `func(nodeType types.NodeType, offset Offset, text string, args []any) (string, []any, []error)` and is called before every node during Tree Construction.
1816-
1817-
If the `NodeArgsTransformer` returns any error, the test suite prints those errors and exits. The text and arguments can be modified, which includes directly changing the args slice that is passed in. Arguments have been flattened already, i.e. none of the entries in args is another []any.
1818-
1819-
The offset is valid for calling NewLocation directly in the implementation of TransformNodeArgs to find the location where the Ginkgo DSL function is called. An additional offset supplied by the caller via args is already included.
1820-
1821-
Additional information about the current node can be obtained by calling `CurrentTreeConstructionNodeReport()` from within the `NodeArgsTransformer`.
1822-
1823-
`AddTreeConstructionNodeArgsTransformer` can be called multiple times - tf there is more than one registered transformer, then the most recently added ones get called first.
1824-
18251811
#### A global label-driven Configuration
18261812

18271813
By attaching `AroundNode` to `RunSpecs` and then using `CurrentSpecReport()` to obtain information about the currently running spec you can control which specs to apply configuration to:
@@ -1937,6 +1923,20 @@ var _ = Describe("the server", func() {
19371923

19381924
`WithField` will receive a `nil` logger as it is invoked during the tree construction phase, not during the run phase when the `BeforeEach` actually runs.
19391925

1926+
### Advanced: Transforming Node Arguments during Tree Construction
1927+
1928+
Ginkgo suites maintained by large communities (👋 Kubernetes) tend to adopt conventions to organize specs with labels and specific decorators. Enforcing these conventions is challenging but can be automated to some degree by inferring developer intent and transforming node arguments, during the Tree Construction phase, to add the relevant Ginkgo decorators.
1929+
1930+
This is done by registering a `NodeArgsTransformer` via `AddTreeConstructionNodeArgsTransformer`. The `NodeArgsTransformer` has signature `func(nodeType types.NodeType, offset Offset, text string, args []any) (string, []any, []error)` and is called before every node during Tree Construction.
1931+
1932+
If the `NodeArgsTransformer` returns any error, the test suite prints those errors and exits. The text and arguments can be modified, which includes directly changing the args slice that is passed in. Arguments have been flattened already, i.e. none of the entries in args is another []any.
1933+
1934+
The offset is valid for calling NewLocation directly in the implementation of TransformNodeArgs to find the location where the Ginkgo DSL function is called. An additional offset supplied by the caller via args is already included.
1935+
1936+
Additional information about the current node can be obtained by calling `CurrentTreeConstructionNodeReport()` from within the `NodeArgsTransformer`.
1937+
1938+
`AddTreeConstructionNodeArgsTransformer` can be called multiple times - tf there is more than one registered transformer, then the most recently added ones get called first.
1939+
19401940
### Alternatives to Dot-Importing Ginkgo
19411941

19421942
As shown throughout this documentation, Ginkgo users are encouraged to dot-import the Ginkgo DSL into their test suites to effectively extend the Go language with Ginkgo's expressive building blocks:

0 commit comments

Comments
 (0)