Skip to content

Commit

Permalink
Use node-definition-id? in chicken-doc 0.4.0; dump sxpath
Browse files Browse the repository at this point in the history
  • Loading branch information
ursetto committed Sep 1, 2010
1 parent 6d5b01a commit 76f4429
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
2 changes: 1 addition & 1 deletion chickadee.meta
Expand Up @@ -7,7 +7,7 @@
(needs matchable uri-common intarweb ; chickadee
(spiffy 4.8) spiffy-request-vars
html-tags html-utils
(chicken-doc 0.3.15) sxpath
(chicken-doc 0.4.0)
sxml-transforms uri-generic (chicken-doc-admin 0.3.13) colorize ; chicken-doc-html
)
(files "chickadee.scm" "chickadee-driver.scm"
Expand Down
25 changes: 3 additions & 22 deletions chickadee.scm
Expand Up @@ -142,18 +142,7 @@
"</ul>\n"
)))))

(use sxpath) ; temp? extract-definitions is in chicken-doc-parser
(use srfi-69)
(define extract-definition-identifiers
(let ((sx (sxpath '(// def sig *))))
(lambda (doc)
(filter-map
(lambda (x)
(let ((type (car x)) (sig (cadr x)) (alist (cddr x)))
(cond ((assq 'id alist) => cadr) ;; Check for pre-parsed ID.
(else
(signature->identifier sig type)))))
(sx doc)))))

(define (format-path p)
(let ((n (handle-exceptions e #f (lookup-node (string-split p)))))
Expand Down Expand Up @@ -192,18 +181,10 @@
;; this could be extended to use relative paths when the current
;; URI permits it, saving some bandwidth.
(define (make-child->href n)
(let ((path (node-path n))
(defids (extract-definition-identifiers (node-sxml n)))
(deftable (make-hash-table string=?))) ; Probably better: merge sort, preferring defs list
(for-each (lambda (id)
(let ((id (->string id)))
(hash-table-set! deftable id
(string-append
"#"
(quote-identifier (definition->identifier id))))))
defids)
(let ((path (node-path n)))
(lambda (id)
(or (hash-table-ref/default deftable (->string id) #f) ;; definition anchor
(if (node-definition-id? n id)
(string-append "#" (quote-identifier (definition->identifier id)))
(path->href (append path (list id)))))))

;; FIXME??? chg "identifier" to html-id (or maybe, fragment to html-id)
Expand Down

0 comments on commit 76f4429

Please sign in to comment.