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 menu
@node Installation
@chapter Installation
@ -209,7 +207,6 @@ example, which demonstrates the utility of both versions.
@menu
@c [[ function-nodes ]]
@end menu
@c [[ function-docs ]]
@node Development

@ -93,8 +93,6 @@ Development
@end detailmenu
@end menu
@node Installation
@chapter Installation
@ -240,17 +238,14 @@ example, which demonstrates the utility of both versions.
* Function combinators::
@end menu
@node Maps
@section Maps
Functions in this category take a transforming function, which
is then applied sequentially to each or selected elements of the
input list. The results are collected in order and returned as a
new list.
@anchor{-map}
@defun -map (fn list)
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 defun
@node Sublist selection
@section Sublist selection
Functions returning a sublist of the original list.
@anchor{-filter}
@defun -filter (pred list)
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 defun
@node List to list
@section List to list
Functions returning a modified copy of the input list.
@anchor{-keep}
@defun -keep (fn 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 defun
@node Reductions
@section Reductions
Functions reducing lists to a single value (which may also be a list).
@anchor{-reduce-from}
@defun -reduce-from (fn init list)
Reduce the function @var{fn} across @var{list}, starting with @var{init}.
@ -1641,15 +1627,12 @@ comparing them.
@end example
@end defun
@node Unfolding
@section Unfolding
Operations dual to reductions, building lists from a seed
value rather than consuming a list to produce a single value.
@anchor{-iterate}
@defun -iterate (fun init n)
Return a list of iterated applications of @var{fun} to @var{init}.
@ -1704,7 +1687,6 @@ the new seed.
@end example
@end defun
@node Predicates
@section Predicates
@ -1936,14 +1918,11 @@ Alias: @code{-cons-pair-p}.
@end example
@end defun
@node Partitioning
@section Partitioning
Functions partitioning the input list into a list of lists.
@anchor{-split-at}
@defun -split-at (n list)
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 defun
@node Indexing
@section Indexing
Return indices of elements based on predicates, sort elements by indices etc.
@anchor{-elem-index}
@defun -elem-index (elem list)
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 defun
@node Set operations
@section Set operations
Operations pretending lists are sets.
@anchor{-union}
@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}.
@ -2582,14 +2555,11 @@ Alias: @code{-uniq}
@end example
@end defun
@node Other list operations
@section Other list operations
Other list functions not fit to be classified elsewhere.
@anchor{-rotate}
@defun -rotate (n list)
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 defun
@node Tree operations
@section Tree operations
Functions pretending lists are trees.
@anchor{-tree-seq}
@defun -tree-seq (branch children tree)
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 defun
@node Threading macros
@section Threading macros
@ -3634,14 +3600,11 @@ which @var{forms} may have modified by side effect.
@end example
@end defmac
@node Binding
@section Binding
Convenient versions of `let` and `let*` constructs combined with flow control.
@anchor{-when-let}
@defmac -when-let ((var val) &rest 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 defmac
@node Side effects
@section Side effects
Functions iterating over lists for side effect only.
@anchor{-each}
@defun -each (list fn)
Call @var{fn} on each element of @var{list}.
@ -4157,7 +4117,6 @@ This function's anaphoric counterpart is @code{--dotimes}.
@end example
@end defun
@node Destructive operations
@section Destructive operations
@ -4193,14 +4152,11 @@ Destructive: Set @var{list} to the cdr of @var{list}.
@end example
@end defmac
@node Function combinators
@section Function combinators
These combinators require Emacs 24 for its lexical scope. So they are offered in a separate package: `dash-functional`.
@anchor{-partial}
@defun -partial (fn &rest args)
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 defun
@node Development
@chapter Development

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

Loading…
Cancel
Save