Skip to content

Commit ed6d55b

Browse files
committed
add scribble/manual-def
Export lower-level facilities used to typeset cross-reference targets and uses based on identifier binding. These facilities are needed to implement new `defproc`-like forms, for example.
1 parent 1b40fc8 commit ed6d55b

File tree

3 files changed

+163
-1
lines changed

3 files changed

+163
-1
lines changed

scribble-doc/scribblings/scribble/manual.scrbl

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
@(require scribble/manual "utils.rkt"
33
(for-syntax racket/base)
44
(for-label scribble/manual-struct
5+
scribble/manual-def
56
racket/list
7+
racket/format
8+
racket/serialize
69
version/utils
710
syntax/quote
811
(only-in scribble/html-properties
@@ -1846,6 +1849,109 @@ signature as a whole to appear right after the signature declaration.}
18461849
Typesets the identifier @racket[id] with a hyperlink to its definition
18471850
as a member of the signature named by @racket[sig-id].}
18481851

1852+
@; ------------------------------------------------------------------------
1853+
@section[#:tag "doc-create"]{Defining Documentation Forms}
1854+
1855+
@defmodule[scribble/manual-def]{The
1856+
@racketmodname[scribble/manual-def] module provides utilities for
1857+
building new documentation forms like @racket[defform] and
1858+
@racket[defproc]. See also @racket[boxed-style] and
1859+
@racket[add-background-label].}
1860+
1861+
@history[#:added "1.64"]
1862+
1863+
@defproc[(make-id-element [id identifier?]
1864+
[str string?]
1865+
[defn? any/c]
1866+
[#:space space (or/c #f symbol?) #f]
1867+
[#:suffix suffix (or/c #f symbol? serializable?) #f]
1868+
[#:link-style link-style (or/c #f style?) #f]
1869+
[#:unlinked-ok? unlinked-ok? any/c #f])
1870+
content?]{
1871+
1872+
Creates an element that typesets @racket[id] as code hyperlinked to
1873+
its definition. The given @racket[str] is used as the identifier's
1874+
typeset form, while @racket[id] is used for its @racket[for-label]
1875+
binding information. If @racket[defn?] is true, the identifier is a
1876+
typeset as the defining instance (for use in a definition box,
1877+
normally).
1878+
1879+
The @racket[space] argument indicates a space (in the sense of
1880+
@racket[only-space-in]) for the binding. The @racket[suffix] argument
1881+
provides an additional suffix on the documentation key, when not
1882+
@racket[#f], and it normally should include @racket[space] if
1883+
@racket[space] is not @racket[#f]. The @racket[suffix] might have
1884+
additional components to, for example, indicate a name syntactically
1885+
accessible via @racket[id], such as through a field-selecting dot
1886+
notation.
1887+
1888+
If @racket[unlinked-ok?] is @racket[#false], then if no link target is
1889+
found based on the @racket[for-label] binding of @racket[id] in
1890+
@racket[space], the identifier is typeset as a failed hyperlink.
1891+
Otherwise, it is typeset without linking.
1892+
1893+
}
1894+
1895+
@defproc[(id-to-target-maker [id identifier?]
1896+
[dep? any/c]
1897+
[#:space space (or/c #f symbol?) #f]
1898+
[#:suffix suffix (or/c #f symbol? serializable?) #f])
1899+
(content? (-> tag? content?) . -> . content?)]{
1900+
1901+
Produces a function to wrap content as a cross-reference link target
1902+
for the defining instance of the binding indicated by @racket[id],
1903+
@racket[space] and @racket[suffix]---which are used as in
1904+
@racket[make-id-element].
1905+
1906+
The resulting @racket[_make-target] procedure expects content that is
1907+
used before the @tech{resolve pass} (e.g., to extract content text)
1908+
plus a procedure that takes a cross-reference tag and produces a
1909+
content representing the specific cross reference target. The
1910+
procedure passed to @racket[_make-target] receives a tag representing
1911+
the binding, and it typically generates a @racket[target-element]
1912+
(possibly a @racket[toc-target2-element]) using that tag. The
1913+
generated @racket[target-element] may also include indexing
1914+
information using the same tag, and where
1915+
@racket[with-exporting-libraries] is used to construct the index
1916+
description.
1917+
1918+
}
1919+
1920+
@defproc[(id-to-form-target-maker [id identifier?]
1921+
[dep? any/c]
1922+
[#:space space (or/c #f symbol?) #f]
1923+
[#:suffix suffix (or/c #f symbol? serializable?) #f])
1924+
(content? (-> tag? content?) . -> . content?)]{
1925+
1926+
Like @racket[id-to-target-maker], but intended for syntactic forms
1927+
instead than value bindings. In the default manual style, both are
1928+
style the same.
1929+
1930+
}
1931+
1932+
1933+
@defproc[(annote-exporting-library [content content?]
1934+
[#:format-module-path fmt (any/c . -> . string?) ~s])
1935+
content?]{
1936+
1937+
Wraps content for a defining instance of some identifier to indicate
1938+
the module path that exports the identifier. This module will be
1939+
determined via @racket[defmodule] or @racket[declare-exporting] in an
1940+
enclosing section.
1941+
1942+
}
1943+
1944+
@defproc[(with-exporting-libraries [make-desc (list? . -> . exported-index-desc?)])
1945+
delayed-index-desc?]{
1946+
1947+
Creates an index description that incorporates information about
1948+
relevant modules. Relevant module paths will be determined via
1949+
@racket[defmodule] or @racket[declare-exporting] in an enclosing
1950+
section and passed to @racket[make-desc], whose result will replace
1951+
the result of @racket[with-exporting-libraries] for indexing.
1952+
1953+
}
1954+
18491955
@; ------------------------------------------------------------------------
18501956
@section[#:tag "doc-strings"]{Various String Forms}
18511957

@@ -2257,6 +2363,20 @@ initial deprecation message.}
22572363

22582364
An alias for @racket[image] for backward compatibility.}
22592365

2366+
@defthing[boxed-style style?]{
2367+
2368+
The style used for a @racket[table] for defining a binding, such as
2369+
the one produced by @racket[defform] or @racket[defproc].
2370+
2371+
}
2372+
2373+
@defproc[(add-background-label [kind string?])
2374+
(-> (list/c block?) block?)]{
2375+
2376+
Produces a function that adds a label to a block in the same way as
2377+
the block produces by @racket[defform], @racket[defproc], etc. The
2378+
block is provided in a flow that has a single block.}
2379+
22602380
@; ------------------------------------------------------------------------
22612381
@section[#:tag "index-entries"]{Index-Entry Descriptions}
22622382

scribble-lib/info.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
(define pkg-authors '(mflatt eli))
2323

24-
(define version "1.63")
24+
(define version "1.64")
2525

2626
(define license
2727
'((Apache-2.0 OR MIT)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#lang racket/base
2+
(require racket/contract/base
3+
racket/serialize
4+
"core.rkt"
5+
(submod "racket.rkt" id-element)
6+
"private/manual-bind.rkt"
7+
"manual-struct.rkt")
8+
9+
(provide
10+
(contract-out
11+
[make-id-element
12+
(->* (identifier?
13+
string?
14+
any/c)
15+
(#:space (or/c #f symbol?)
16+
#:suffix (or/c #f symbol? serializable?)
17+
#:link-style (or/c #f style?)
18+
#:unlinked-ok? any/c)
19+
content?)]
20+
[id-to-target-maker
21+
(->* (identifier?
22+
any/c)
23+
(#:space (or/c #f symbol?)
24+
#:suffix (or/c #f symbol? serializable?))
25+
(-> content?
26+
(-> tag? content?)
27+
content?))]
28+
[id-to-form-target-maker
29+
(->* (identifier?
30+
any/c)
31+
(#:space (or/c #f symbol?)
32+
#:suffix (or/c #f symbol? serializable?))
33+
(-> content?
34+
(-> tag? content?)
35+
content?))]
36+
[annote-exporting-library
37+
(->* (content?)
38+
(#:format-module-path (any/c . -> . string?))
39+
content?)]
40+
[with-exporting-libraries
41+
(->* ((list? . -> . exported-index-desc?))
42+
delayed-index-desc?)]))

0 commit comments

Comments
 (0)