Skip to content

Commit

Permalink
Merge pull request #56 from 40ants/autodoc-for-types
Browse files Browse the repository at this point in the history
Type definitions now supported by 40ANTS-DOC/AUTODOC:DEFAUTODOC macro.
  • Loading branch information
svetlyak40wt authored Dec 14, 2024
2 parents 3336fe0 + 5f8d3e7 commit e0258e9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
27 changes: 24 additions & 3 deletions full/locatives/type.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,33 @@
(cons locative-type locative-args)))
(arglist (swank-backend:type-specifier-arglist symbol))
(docstring (40ants-doc/docstring:get-docstring symbol 'type))
(children (when docstring
(40ants-doc-full/commondoc/markdown:parse-markdown docstring))))
(docstring-children
(when docstring
(40ants-doc-full/commondoc/markdown:parse-markdown docstring)))
(type-expansion
#+sbcl
(multiple-value-bind (expansion ok)
(handler-case (sb-ext:typexpand-1 symbol)
(serious-condition ()
(values nil nil)))
(when ok
expansion))
#-sbcl
nil)
(expansion-children
(when type-expansion
(40ants-doc-full/commondoc/markdown:parse-markdown
(with-output-to-string (s)
(format s "```
~S
```"
type-expansion))))))

(40ants-doc-full/commondoc/bullet:make-bullet reference
:arglist arglist
:children children
:children (remove nil
(list docstring-children
expansion-children))
:ignore-words symbol)))


Expand Down
9 changes: 9 additions & 0 deletions src/autodoc.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#:section
#:defsection)
(:import-from #:str)
(:import-from #:swank-backend)
(:import-from #:alexandria
#:symbolicate)
(:import-from #:40ants-doc/locatives
Expand Down Expand Up @@ -144,6 +145,13 @@
when (documentation symbol 'variable)
collect (list symbol 'variable) into variables

;; Types and not classes
when (and (not (find-class symbol nil))
(or (documentation symbol 'type)
(not (eq (swank-backend:type-specifier-arglist symbol)
:not-available))))
collect (list symbol 'type) into types

finally (return
(uiop:while-collecting (collect)
(flet ((add-subsection (entries title)
Expand All @@ -164,6 +172,7 @@
(add-subsection generics "Generics")
(add-subsection functions "Functions")
(add-subsection macros "Macros")
(add-subsection types "Types")
(add-subsection variables "Variables")))))))
(when entries
`(defsection ,section-name (:title ,title
Expand Down
4 changes: 4 additions & 0 deletions src/changelog.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"CSS"
"SLY"
"API"
"SBCL"
"COMMONDOC:SECTION"
"COLLECT-REACHABLE-OBJECTS"
"LOCATE-AND-COLLECT-REACHABLE-OBJECTS"
Expand All @@ -153,6 +154,9 @@
"CLEAN-URLS"
;; These objects are not documented yet:
"40ANTS-DOC/COMMONDOC/XREF:XREF"))
(0.20.0 2024-12-14
"* Type definitions now supported by 40ANTS-DOC/AUTODOC:DEFAUTODOC macro.
* Type expansion is shown for type definitions when building doc on SBCL.")
(0.19.0 2024-12-13
"* Argument IGNORE-PACKAGES was added to 40ANTS-DOC/AUTODOC:DEFAUTODOC macro.
It can be used to exclude some packages from autogenerated docs.
Expand Down

0 comments on commit e0258e9

Please sign in to comment.