-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit makes it possible to customize pretty-printing of captured variables. It's possible to tweak pretty-printing based on - runtime type of binder - string representation of static type of binder - position of binder in either enclosing statment or section This change required improving the handling of blank lines so that users that customize pretty-printing don't fiddle with brittle `\n` manipulation.
- Loading branch information
Showing
14 changed files
with
317 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,6 @@ object Docs { | |
) | ||
) | ||
) | ||
sys.exit(exitCode) | ||
if (exitCode != 0) sys.exit(exitCode) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package mdoc | ||
|
||
import mdoc.internal.markdown.ReplVariablePrinter | ||
|
||
/** | ||
* A captured variable in a code fence. | ||
* | ||
* Example, the code fence below has two statements: | ||
* | ||
* - The first statement has a single variable with name `x` | ||
* - The second statement has a two variables with names `y` and `z` | ||
* | ||
* {{{ | ||
* ```scala mdoc | ||
* val x = 1 | ||
* val (y, z) = (2, 3) | ||
* ``` | ||
* }}} | ||
* | ||
* @param name the variable name, for example `x` | ||
* @param staticType the pretty-printed static type of this variable, for example `List[Int]` | ||
* @param runtimeValue the runtime value of this variable. | ||
* @param indexOfVariableInStatement the index of this variable in the enclosing statement. | ||
* For example, in `val (a, b) = ???` the variable `a` has index | ||
* 0 and variable `b` has index `1`. | ||
* @param totalVariablesInStatement The total number of variables in this statements. For example, | ||
* in `val a = N` the total number is 1 and for `val (a, b) = ...` the | ||
* total number is 2. | ||
* @param indexOfStatementInCodeFence the index of the enclosing statement within the enclosing code fence. | ||
* For example, in | ||
* {{{ | ||
* ```scala | ||
* val x = 1 | ||
* val y = 2 | ||
* ``` | ||
* }}} | ||
* The variable `y` has index 1 and variable `x` has index 0. | ||
* @param totalStatementsInCodeFence the total number of statement in the enclosing code fence. | ||
* For example, the total number is 2 for the code fence below. | ||
* {{{ | ||
* ```scala | ||
* val x = 1 | ||
* val y = 2 | ||
* ``` | ||
* }}} | ||
* | ||
*/ | ||
final class Variable private[mdoc] ( | ||
val name: String, | ||
val staticType: String, | ||
val runtimeValue: Any, | ||
val indexOfVariableInStatement: Int, | ||
val totalVariablesInStatement: Int, | ||
val indexOfStatementInCodeFence: Int, | ||
val totalStatementsInCodeFence: Int | ||
) { | ||
def isUnit: Boolean = staticType.endsWith("Unit") | ||
override def toString: String = { | ||
ReplVariablePrinter(this) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.