From c48ecda020797fe3fe65d55d02a8b72f6e7f19cb Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Thu, 17 Feb 2022 09:27:40 -0600 Subject: add whole classes to documentation --- example/lazybones-example.lisp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'example/lazybones-example.lisp') diff --git a/example/lazybones-example.lisp b/example/lazybones-example.lisp index 5eb00d9..018b4ae 100644 --- a/example/lazybones-example.lisp +++ b/example/lazybones-example.lisp @@ -135,3 +135,35 @@ } ") + +(defclass animal () + ((genus :initarg :genus :documentation "The genus") + (species :initarg :species :documentation "The species") + (population :initarg :population :documentation "Population on Earth") + (habitat :initarg :habitat :documentation "Where the animal lives")) + (:documentation "An animal")) + +;; add a documentation definition for animal class, the provided slots +;; will show up in the api docs +(lzb:add-class-to-definitions (lzb:app) + 'animal + 'genus 'species 'population 'habitat) + +(defvar +dummy-animal+ + (make-instance 'animal + :genus "Pseudocheirus" + :species "Peregrinis" + :population "Unknown" + :habitat "Australia")) + +;; you can refer to definitions in docstrings +(defendpoint* :get "/animal/:genus:/:species:" () () + "Prints information about [Animal](#animal) specified by GENUS and SPECIES" + (if (and (string-equal genus "Pseudocheirus") + (string-equal species "Peregrinis")) + (with-output-to-string (out) + (with-slots (genus species population habitat) +dummy-animal+ + (format out "The ~a ~a lives in ~a. Population: ~a~%" + genus species population habitat))) + (http-err 404))) + -- cgit v1.2.3