History

sym-set-doc: fix trim-indent

Find the least indented line instead of just using the second one. Also encourage using verbatim strings («») in docstrings.

Sigrid Solveig Haflínudóttir committed 4 months ago

Commit ee261ec1 parent 1c8976d3 files · +54 −59Browse files

Showing the changes to src (2 of 3 files). Show all

Unified · Split

2 files
  1. src/docs.sl +6 −6
  2. src/system.sl +10 −14
src/docs.sl+6−6
@@ -19,16 +19,16 @@ · 18 unmodified lines
1919 by `defstruct` to provide full constructor description in the output.»
2020 :doc-example
2121 «(defdoc (func arg (arg2 0))
22− "Return something about the `arg` and `arg2`. This is a short
22+ «Return something about the `arg` and `arg2`. This is a short
2323 description.
2424
25− This is the longer description, following the short one."
25+ This is the longer description, following the short one.\»
2626 :doc-example
27− "(func 0)
28− ; ↳ T"
27+ «(func 0)
28+ ; ↳ T\»
2929 :doc-example
30− "(func 1 3)
31− ; ↳ NIL"
30+ «(func 1 3)
31+ ; ↳ NIL\»
3232 :doc-group stuff
3333 :doc-see func2
3434 :doc-fmt (λ (doc) doc)
src/system.sl+10−14
@@ -169,14 +169,10 @@ · 168 unmodified lines
169169 (let* {[lines (str-split s "\n")]
170170 [hd (car lines)]
171171 [tl (cdr lines)]
172− [snd (any (λ (s) (and (> (length s) 0)
173− (rune-whitespace? (str-rune s 0))
174− s))
175− tl)]
176− [indent (and snd
177− (- (length snd)
178− (length (str-trim snd))))]
179− [trimmed (and snd
172+ [indent (and tl (apply min (map (λ (s) (and (> (length s) 0)
173+ (- (length s) (length (str-trim s)))))
174+ tl)))]
175+ [trimmed (and tl
180176 (map (λ (s) (if (<= indent (length s))
181177 (str-sub s indent)
182178 s))
@@ -1658,7 +1654,7 @@ · 1475 unmodified lines
16581654 «Define a new macro.»
16591655 :doc-example
16601656 «(defmacro (inc! v)
1661− "Increments and returns the value."
1657+ «Increments and returns the value.\»
16621658 :doc-group my-cool-macros
16631659 :doc-see my-other-cool-macro
16641660 (if (num? v)
@@ -1749,10 +1745,10 @@ · 84 unmodified lines
17491745 :doc-example
17501746 «; a function with documentation (first form)
17511747 (def (f x)
1752− "Return the square of doubled `x`."
1748+ «Return the square of doubled `x`.\»
17531749 :doc-example
1754− "(f 3)
1755− ; ↳ 36"
1750+ «(f 3)
1751+ ; ↳ 36\»
17561752 :doc-group cool-funcs ; documentation group for (help groups)
17571753 :doc-see g ; reference another function in the documentation
17581754 (def (g y) ; an internal function
@@ -2110,7 +2106,7 @@ · 351 unmodified lines
21102106 If no `else` was specified and no matches occured, `NIL` is
21112107 returned.»
21122108 :doc-example
2113− «(case 'c ; match present
2109+ «(case 'c ; match present
21142110 (a 0)
21152111 ((b c d) 1))
21162112 ; ↳ b»
@@ -2122,7 +2118,7 @@ · 5 unmodified lines
21222118 (newline))
21232119 ; ‼ yay»
21242120 :doc-example
2125− «(case "c" ; no matches, without else
2121+ «(case "c" ; no matches, without else
21262122 ("a" 0)
21272123 ("b" 1))
21282124 ; ↳ NIL»

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t