Skip to content

Commit

Permalink
[add] links to parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Mc-Zen committed Nov 26, 2024
1 parent 476408d commit 4310154
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
8 changes: 6 additions & 2 deletions docs/template.typ
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@
show heading.where(level: 3): set text(1.2em)

// show link: set text(fill: purple.darken(30%))
show link: set text(fill: rgb("#1e8f6f"))
show link: underline
show link: it => {
let dest = str(it.dest)
if "." in dest and not "/" in dest { return underline(it, stroke: luma(60%), offset: 1pt) }
set text(fill: rgb("#1e8f6f"))
underline(it)
}

v(4em)

Expand Down
11 changes: 10 additions & 1 deletion docs/tidy-guide.typ
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ In the output, the preview of the code examples is shown next to it.
read("/examples/wiggly.typ"),
name: "wiggly",
scope: (wiggly: wiggly),
label-prefix: "wiggly1-",
preamble: "#import wiggly: *\n",
old-syntax: false
)
Expand Down Expand Up @@ -299,6 +300,7 @@ Currently, the two predefined styles `tidy.styles.default` and `tidy-styles.mini
read("/examples/wiggly.typ"),
name: "wiggly",
scope: (wiggly: wiggly),
label-prefix: "wiggly2-",
preamble: "#import wiggly: *\n",
old-syntax: false
)
Expand Down Expand Up @@ -471,8 +473,15 @@ Let us now _self-document_ this package:

#let style = tidy.styles.default
#{
set heading(numbering: none)
set text(size: 9pt)
set heading(numbering: none)
show heading.where(level: 3): set text(1.5em)
show heading.where(level: 4): it => {
set text(1.4em)
set align(center)
set block(below: 1.2em)
it
}

let module = tidy.parse-module(
(
Expand Down
3 changes: 3 additions & 0 deletions src/styles/default.typ
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
if "types" in description {
types = ": " + description.types.map(x => show-type(x, style-args: style-args)).join(" ")
}
if style-args.enable-cross-references and not (description.description == "" and style-args.omit-empty-param-descriptions) {
name = link(label(style-args.label-prefix + fn.name + "." + name.trim(".")), name)
}
items.push(name + types)
}
items.join( if inline-args {", "} else { ",\n "})
Expand Down
9 changes: 6 additions & 3 deletions src/styles/minimal.typ
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@
let inline-args = fn.args.len() < 5
if not inline-args { "\n " }
let items = ()
for (arg-name, info) in fn.args {
if style-args.omit-private-parameters and arg-name.starts-with("_") {
for (name, info) in fn.args {
if style-args.omit-private-parameters and name.starts-with("_") {
continue
}
let types
if "types" in info {
types = ": " + info.types.map(x => show-type(x)).join(" ")
}
items.push(box(arg-name + types))
if style-args.enable-cross-references and not (info.description == "" and style-args.omit-empty-param-descriptions) {
name = link(label(style-args.label-prefix + fn.name + "." + name.trim(".")), name)
}
items.push(box(name + types))
}
items.join( if inline-args {", "} else { ",\n "})
if not inline-args { "\n" } + ")"
Expand Down

0 comments on commit 4310154

Please sign in to comment.