From 6fd22846f21b8b70b7867e989109d14a366c0a3e Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 14 Aug 2021 03:09:58 -0400 Subject: Moved documentation-generation machinery to its own module. --- stdlib/source/library/lux.lux | 44 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) (limited to 'stdlib/source/library/lux.lux') diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 16123c586..f534a51d9 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -2496,10 +2496,11 @@ [(def:''' .private ( xy) #End (All [a b] (-> (Tuple a b) )) - (let' [[x y] xy] ))] + (let' [[x y] xy] + ))] - [first a x] - [second b y]) + [product\left a x] + [product\right b y]) (def:''' .private (type_declaration type_codes) #End @@ -2516,8 +2517,8 @@ (failure "Wrong syntax for variant case.")} pair))) pairs)] - (in_meta [(` (Tuple (~+ (list\map second members)))) - (#Some (list\map first members))])) + (in_meta [(` (Tuple (~+ (list\map product\right members)))) + (#Some (list\map product\left members))])) (#Item type #End) ({[_ (#Tag "" member_name)] @@ -2548,8 +2549,8 @@ (failure "Wrong syntax for variant case.")} case))) (list& case cases))] - (in_meta [(` (..Variant (~+ (list\map second members)))) - (#Some (list\map first members))])) + (in_meta [(` (..Variant (~+ (list\map product\right members)))) + (#Some (list\map product\left members))])) _ (failure "Improper type-definition syntax")} @@ -3551,7 +3552,7 @@ _ (failure "No tags available for type."))) .let [tag_mappings (: (List [Text Code]) - (list\map (function (_ tag) [(second tag) (tag$ tag)]) + (list\map (function (_ tag) [(product\right tag) (tag$ tag)]) tags))] members (monad\map meta_monad (: (-> Code (Meta [Code Code])) @@ -5033,8 +5034,8 @@ [[_ _ column] (#Record pairs)] (list\fold n/min column - (list\compose (list\map (|>> first baseline_column) pairs) - (list\map (|>> second baseline_column) pairs))) + (list\compose (list\map (|>> product\left baseline_column) pairs) + (list\map (|>> product\right baseline_column) pairs))) )) (type: Documentation_Fragment @@ -5086,16 +5087,11 @@ (-> Location Text Location) [file line ("lux i64 +" column (text\size code_text))]) -(def: (delimiter_updated_location [file line column]) - (-> Location Location) - [file line (inc column)]) - (def: un_paired (-> (List [Code Code]) (List Code)) (let [pair_list (: (-> [Code Code] (List Code)) - (function (_ pair) - (let [[left right] pair] - (list left right))))] + (function (_ [left right]) + (list left right)))] (|>> (list\map pair_list) list\join))) @@ -5121,9 +5117,9 @@ (let [[group_location' parts_text] (list\fold (function (_ part [last_location text_accum]) (let [[part_location part_text] (example_documentation last_location baseline part)] [part_location (text\compose text_accum part_text)])) - [(delimiter_updated_location group_location) ""] + [(update@ #column inc group_location) ""] ( parts))] - [(delimiter_updated_location group_location') + [(update@ #column inc group_location') ($_ text\compose (location_padding baseline prev_location group_location) parts_text @@ -5136,10 +5132,6 @@ ("lux io error" "@example_documentation Undefined behavior.") )) -(def: (with_baseline baseline [file line column]) - (-> Nat Location Location) - [file line baseline]) - (def: (fragment_documentation fragment) (-> Documentation_Fragment Text) (case fragment @@ -5152,7 +5144,7 @@ (#Documentation_Example example) (let [baseline (baseline_column example) [location _] example - [_ text] (..example_documentation (with_baseline baseline location) baseline example)] + [_ text] (..example_documentation (set@ #.column baseline location) baseline example)] (text\compose text __paragraph)))) (macro: .public (example tokens) @@ -5246,8 +5238,8 @@ (case ?params (#.Some [name bindings body]) (let [pairs (pairs bindings) - vars (list\map first pairs) - inits (list\map second pairs)] + vars (list\map product\left pairs) + inits (list\map product\right pairs)] (if (every? identifier? inits) (do meta_monad [inits' (: (Meta (List Name)) -- cgit v1.2.3