Skip to content

Commit

Permalink
Render multi-line types with triple backticks
Browse files Browse the repository at this point in the history
Arguably this shouldn't even be allowed, but erroring would not be in line
with how nixdoc works otherwise :)
  • Loading branch information
infinisil committed Jul 20, 2023
1 parent a493977 commit f8e002e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/commonmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ impl ManualEntry {

// <subtitle> (type signature)
if let Some(t) = &self.fn_type {
writeln!(writer, "**Type**: `{}`\n", t)?;
if t.lines().count() > 1 {
writeln!(writer, "**Type**:\n```\n{}\n```\n", t)?;
} else {
writeln!(writer, "**Type**: `{}`\n", t)?;
}
}

// Primary doc string
Expand Down
21 changes: 15 additions & 6 deletions src/snapshots/nixdoc__main.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1092,10 +1092,13 @@ Located at [lib/strings.nix:735](https://github.com/NixOS/nixpkgs/blob/580dd2124
## `lib.strings.mesonOption` {#function-library-lib.strings.mesonOption}
**Type**: `mesonOption :: string -> string -> string
**Type**:
```
mesonOption :: string -> string -> string
@param feature The feature to be set
@param value The desired value`
@param value The desired value
```
Create a -D<feature>=<value> string that can be passed to typical Meson
invocations.
Expand Down Expand Up @@ -1123,10 +1126,13 @@ Located at [lib/strings.nix:754](https://github.com/NixOS/nixpkgs/blob/580dd2124
## `lib.strings.mesonBool` {#function-library-lib.strings.mesonBool}
**Type**: `mesonBool :: string -> bool -> string
**Type**:
```
mesonBool :: string -> bool -> string
@param condition The condition to be made true or false
@param flag The controlling flag of the condition`
@param flag The controlling flag of the condition
```
Create a -D<condition>={true,false} string that can be passed to typical
Meson invocations.
Expand Down Expand Up @@ -1156,10 +1162,13 @@ Located at [lib/strings.nix:773](https://github.com/NixOS/nixpkgs/blob/580dd2124
## `lib.strings.mesonEnable` {#function-library-lib.strings.mesonEnable}
**Type**: `mesonEnable :: string -> bool -> string
**Type**:
```
mesonEnable :: string -> bool -> string
@param feature The feature to be enabled or disabled
@param flag The controlling flag`
@param flag The controlling flag
```
Create a -D<feature>={enabled,disabled} string that can be passed to
typical Meson invocations.
Expand Down

0 comments on commit f8e002e

Please sign in to comment.