Skip to content

Commit

Permalink
Updated source code doc
Browse files Browse the repository at this point in the history
  • Loading branch information
SalomonBrys committed May 9, 2024
1 parent 2a3812e commit dc326c1
Showing 1 changed file with 14 additions and 33 deletions.
47 changes: 14 additions & 33 deletions docs/modules/core/pages/source-code.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ val m by marker(hidden(0), highlighted(2))
----


=== Debuging your sections

You can display your source code with all of your sections visually framed, which will allow you to visually understand how your sections are defined.
Give a `SourceCodeDebugColors` to the `debug` parameter of the `SourceCode` function:

[source, kotlin]
----
SourceCode(
sourceCode = sourceCode,
debug = SourceCodeDebugColors(),
)
----


=== Display

You then need to pass the current `step` to `SourceCode`:
Expand Down Expand Up @@ -197,39 +211,6 @@ Here are the same sections, but *CORRECT*:
====


=== Implicit & explicit steps

Using your defined markers, CuP counts the number of steps that your source code will be colored and animated.
For example, considering the following markers:

[source, kotlin]
----
val a by marker(onlyShown(0))
val b by marker(hidden(0))
val c by marker(hidden(0..1))
val d by marker(highlighted(3))
----

Here, CuP will infer that your animation contains 4 steps (numbered 0 to 3).
Even though step 2 is never defined, because marker `d` defines a step 3, then step 2 must exist!

However, if the last step of your animation is defined nowhere, then it needs to be explicitely defined:

[source, kotlin]
----
val sourceCode = rememberSourceCode(language = "text") {
val bad by marker(onlyShown(0))
val good by marker(hidden(0))
ensureStep(1) //<1>
"""
This is ${bad}freaking${X}${good}really${X} amazing!
""".trimIndent()
}
----
<1> Because step 1 is defined nowhere, and it is the last step, it needs to be explicitly defined.


[[style]]
== Applying additional styles

Expand Down

0 comments on commit dc326c1

Please sign in to comment.