Improve function-to-info

* dev/examples-to-info.el (function-to-node): Simplify.
(function-to-info): Ditto.  Remove gratuitous newlines.
(s-replace): Remove function; no longer used.
* dash-template.texi (Top, Functions): Remove gratuitous newlines.
* dash.texi: Regenerate.
master
Basil L. Contovounesios 5 years ago
parent dbbf617c28
commit bedc804da3
No known key found for this signature in database
GPG Key ID: 205AB54A5D5D8CFF
  1. 3
      dash-template.texi
  2. 45
      dash.texi
  3. 42
      dev/examples-to-info.el

@ -78,8 +78,6 @@ Development
@end detailmenu @end detailmenu
@end menu @end menu
@node Installation @node Installation
@chapter Installation @chapter Installation
@ -209,7 +207,6 @@ example, which demonstrates the utility of both versions.
@menu @menu
@c [[ function-nodes ]] @c [[ function-nodes ]]
@end menu @end menu
@c [[ function-docs ]] @c [[ function-docs ]]
@node Development @node Development

@ -93,8 +93,6 @@ Development
@end detailmenu @end detailmenu
@end menu @end menu
@node Installation @node Installation
@chapter Installation @chapter Installation
@ -240,17 +238,14 @@ example, which demonstrates the utility of both versions.
* Function combinators:: * Function combinators::
@end menu @end menu
@node Maps @node Maps
@section Maps @section Maps
Functions in this category take a transforming function, which Functions in this category take a transforming function, which
is then applied sequentially to each or selected elements of the is then applied sequentially to each or selected elements of the
input list. The results are collected in order and returned as a input list. The results are collected in order and returned as a
new list. new list.
@anchor{-map} @anchor{-map}
@defun -map (fn list) @defun -map (fn list)
Apply @var{fn} to each item in @var{list} and return the list of results. Apply @var{fn} to each item in @var{list} and return the list of results.
@ -475,14 +470,11 @@ Create a shallow copy of @var{list}.
@end example @end example
@end defun @end defun
@node Sublist selection @node Sublist selection
@section Sublist selection @section Sublist selection
Functions returning a sublist of the original list. Functions returning a sublist of the original list.
@anchor{-filter} @anchor{-filter}
@defun -filter (pred list) @defun -filter (pred list)
Return a new list of the items in @var{list} for which @var{pred} returns non-nil. Return a new list of the items in @var{list} for which @var{pred} returns non-nil.
@ -861,14 +853,11 @@ See also: @code{-select-columns} (@pxref{-select-columns}), @code{-select-by-ind
@end example @end example
@end defun @end defun
@node List to list @node List to list
@section List to list @section List to list
Functions returning a modified copy of the input list. Functions returning a modified copy of the input list.
@anchor{-keep} @anchor{-keep}
@defun -keep (fn list) @defun -keep (fn list)
Return a new list of the non-nil results of applying @var{fn} to each item in @var{list}. Return a new list of the non-nil results of applying @var{fn} to each item in @var{list}.
@ -1144,14 +1133,11 @@ See also: @code{-remove-at} (@pxref{-remove-at}), @code{-remove} (@pxref{-remove
@end example @end example
@end defun @end defun
@node Reductions @node Reductions
@section Reductions @section Reductions
Functions reducing lists to a single value (which may also be a list). Functions reducing lists to a single value (which may also be a list).
@anchor{-reduce-from} @anchor{-reduce-from}
@defun -reduce-from (fn init list) @defun -reduce-from (fn init list)
Reduce the function @var{fn} across @var{list}, starting with @var{init}. Reduce the function @var{fn} across @var{list}, starting with @var{init}.
@ -1641,15 +1627,12 @@ comparing them.
@end example @end example
@end defun @end defun
@node Unfolding @node Unfolding
@section Unfolding @section Unfolding
Operations dual to reductions, building lists from a seed Operations dual to reductions, building lists from a seed
value rather than consuming a list to produce a single value. value rather than consuming a list to produce a single value.
@anchor{-iterate} @anchor{-iterate}
@defun -iterate (fun init n) @defun -iterate (fun init n)
Return a list of iterated applications of @var{fun} to @var{init}. Return a list of iterated applications of @var{fun} to @var{init}.
@ -1704,7 +1687,6 @@ the new seed.
@end example @end example
@end defun @end defun
@node Predicates @node Predicates
@section Predicates @section Predicates
@ -1936,14 +1918,11 @@ Alias: @code{-cons-pair-p}.
@end example @end example
@end defun @end defun
@node Partitioning @node Partitioning
@section Partitioning @section Partitioning
Functions partitioning the input list into a list of lists. Functions partitioning the input list into a list of lists.
@anchor{-split-at} @anchor{-split-at}
@defun -split-at (n list) @defun -split-at (n list)
Split @var{list} into two sublists after the Nth element. Split @var{list} into two sublists after the Nth element.
@ -2292,14 +2271,11 @@ elements of @var{list}. Keys are compared by @code{equal}.
@end example @end example
@end defun @end defun
@node Indexing @node Indexing
@section Indexing @section Indexing
Return indices of elements based on predicates, sort elements by indices etc. Return indices of elements based on predicates, sort elements by indices etc.
@anchor{-elem-index} @anchor{-elem-index}
@defun -elem-index (elem list) @defun -elem-index (elem list)
Return the index of the first element in the given @var{list} which Return the index of the first element in the given @var{list} which
@ -2448,14 +2424,11 @@ permutation to @var{list} sorts it in descending order.
@end example @end example
@end defun @end defun
@node Set operations @node Set operations
@section Set operations @section Set operations
Operations pretending lists are sets. Operations pretending lists are sets.
@anchor{-union} @anchor{-union}
@defun -union (list list2) @defun -union (list list2)
Return a new list containing the elements of @var{list} and elements of @var{list2} that are not in @var{list}. Return a new list containing the elements of @var{list} and elements of @var{list2} that are not in @var{list}.
@ -2582,14 +2555,11 @@ Alias: @code{-uniq}
@end example @end example
@end defun @end defun
@node Other list operations @node Other list operations
@section Other list operations @section Other list operations
Other list functions not fit to be classified elsewhere. Other list functions not fit to be classified elsewhere.
@anchor{-rotate} @anchor{-rotate}
@defun -rotate (n list) @defun -rotate (n list)
Rotate @var{list} @var{n} places to the right. With @var{n} negative, rotate to the left. Rotate @var{list} @var{n} places to the right. With @var{n} negative, rotate to the left.
@ -3249,14 +3219,11 @@ Compute the (least) fixpoint of @var{fn} with initial input @var{list}.
@end example @end example
@end defun @end defun
@node Tree operations @node Tree operations
@section Tree operations @section Tree operations
Functions pretending lists are trees. Functions pretending lists are trees.
@anchor{-tree-seq} @anchor{-tree-seq}
@defun -tree-seq (branch children tree) @defun -tree-seq (branch children tree)
Return a sequence of the nodes in @var{tree}, in depth-first search order. Return a sequence of the nodes in @var{tree}, in depth-first search order.
@ -3449,7 +3416,6 @@ structure such as plist or alist.
@end example @end example
@end defun @end defun
@node Threading macros @node Threading macros
@section Threading macros @section Threading macros
@ -3634,14 +3600,11 @@ which @var{forms} may have modified by side effect.
@end example @end example
@end defmac @end defmac
@node Binding @node Binding
@section Binding @section Binding
Convenient versions of `let` and `let*` constructs combined with flow control. Convenient versions of `let` and `let*` constructs combined with flow control.
@anchor{-when-let} @anchor{-when-let}
@defmac -when-let ((var val) &rest body) @defmac -when-let ((var val) &rest body)
If @var{val} evaluates to non-nil, bind it to @var{var} and execute body. If @var{val} evaluates to non-nil, bind it to @var{var} and execute body.
@ -4009,14 +3972,11 @@ multiple assignments it does not cause unexpected side effects.
@end example @end example
@end defmac @end defmac
@node Side effects @node Side effects
@section Side effects @section Side effects
Functions iterating over lists for side effect only. Functions iterating over lists for side effect only.
@anchor{-each} @anchor{-each}
@defun -each (list fn) @defun -each (list fn)
Call @var{fn} on each element of @var{list}. Call @var{fn} on each element of @var{list}.
@ -4157,7 +4117,6 @@ This function's anaphoric counterpart is @code{--dotimes}.
@end example @end example
@end defun @end defun
@node Destructive operations @node Destructive operations
@section Destructive operations @section Destructive operations
@ -4193,14 +4152,11 @@ Destructive: Set @var{list} to the cdr of @var{list}.
@end example @end example
@end defmac @end defmac
@node Function combinators @node Function combinators
@section Function combinators @section Function combinators
These combinators require Emacs 24 for its lexical scope. So they are offered in a separate package: `dash-functional`. These combinators require Emacs 24 for its lexical scope. So they are offered in a separate package: `dash-functional`.
@anchor{-partial} @anchor{-partial}
@defun -partial (fn &rest args) @defun -partial (fn &rest args)
Take a function @var{fn} and fewer than the normal arguments to @var{fn}, Take a function @var{fn} and fewer than the normal arguments to @var{fn},
@ -4562,7 +4518,6 @@ This function satisfies the following laws:
@end example @end example
@end defun @end defun
@node Development @node Development
@chapter Development @chapter Development

@ -105,32 +105,26 @@ Based on `describe-function-1'."
it t t)))) it t t))))
(defun function-to-node (function) (defun function-to-node (function)
(let ((case-fold-search nil)) (concat (replace-regexp-in-string (rx bos "### ") "* " function t t) "::"))
(string-match "^\\(### [[:upper:]][[:alpha:]- ]+\\)$" function)
(concat (s-replace "### " "* " (match-string 1 function)) "::")))
(defun function-to-info (function) (defun function-to-info (function)
(if (stringp function) (pcase function
(concat "\n" (s-replace "### " "@node " function) "\n" (`(,command-name ,signature ,docstring ,examples)
(when (string-match "^### " function) (let ((type (if (macrop command-name) "defmac" "defun")))
(s-replace "### " "@section " function)) "\n") (format (concat "\n@anchor{%s}\n"
(-let [(command-name signature docstring examples) function] "@" type " %s %s\n"
(format (concat "@anchor{%s}\n" "%s\n\n"
(if (macrop command-name) "@defmac" "@defun") "@example\n%s\n@end example\n"
" %s %s\n" "@end " type)
"%s\n\n" command-name
"@example\n%s\n@end example\n" command-name
"@end " signature
(if (macrop command-name) "defmac" "defun") "\n") (format-docstring docstring)
command-name (mapconcat #'identity (-take 3 examples) "\n"))))
command-name ((rx bos "### ")
signature (setq function (substring function (match-end 0)))
(format-docstring docstring) (concat "\n@node " function "\n@section " function))
(mapconcat 'identity (-take 3 examples) "\n"))))) (_ (concat "\n" function))))
(defun s-replace (old new s)
"Replace OLD with NEW in S."
(replace-regexp-in-string (regexp-quote old) new s t t))
(defun simplify-quotes () (defun simplify-quotes ()
(goto-char (point-min)) (goto-char (point-min))

Loading…
Cancel
Save