跨多个文件拆分时声明 defproc 或变形的模块(function/macro 文档)
Declaring the module of a defproc or deform (function/macro documentation) when split across multiple files
在 scribble 中,我可以使用文件中的 defproc
and defform
to define the documentation for a function or macro. And then scribble uses the nearest defform
来确定 function/macro 定义在哪个模块中。
但是,有时将同一模块的文档分成多个涂鸦文件有时是有意义的。
(假设您希望 init
函数的文档位于 repl.scrbl
中,并且您希望 find
的文档位于 api.scrbl
中。但是两者它们在同一个模块中定义,比如 repl.rkt
.)
但是,当文档中有多个相同 defmodule
的证实时,Scribble 会抱怨:
WARNING: collected information for key multiple times: '(index-entry (mod-path "zordoz")); values: (list '("zordoz") (list (link-element (style "RktModLink" (list 'tt-chars #0=(list (css-addition '(collects #"scribble" #"racket.css")) (tex-addition '(collects #"scribble" #"racket.tex"))))) (cached-element (style "RktSym" (list 'tt-chars #0#)) "zordoz... (list '("zordoz") (list (link-element (style "RktModLink" (list 'tt-chars #0=(list (css-addition '(collects #"scribble" #"racket.css")) (tex-addition '(collects #"scribble" #"racket.tex"))))) (cached-element (style "RktSym" (list 'tt-chars #0#)) "zordoz...
WARNING: collected information for key multiple times: '(mod-path "zordoz"); values: '#(("REPL") (mod-path "zordoz") (2) (doc #"main" #"index.html") #f) '#(("API") (mod-path "zordoz") (3) (doc #"main" #"index.html") #f)
raco setup: rendering: <pkgs>/zordoz/scribblings/main.scrbl
WARNING: collected information for key multiple times: '(index-entry (mod-path "zordoz")); values: (list '("zordoz") (list (link-element (style "RktModLink" (list 'tt-chars #0=(list (css-addition '(collects #"scribble" #"racket.css")) (tex-addition '(collects #"scribble" #"racket.tex"))))) (cached-element (style "RktSym" (list 'tt-chars #0#)) "zordoz... (list '("zordoz") (list (link-element (style "RktModLink" (list 'tt-chars #0=(list (css-addition '(collects #"scribble" #"racket.css")) (tex-addition '(collects #"scribble" #"racket.tex"))))) (cached-element (style "RktSym" (list 'tt-chars #0#)) "zordoz...
WARNING: collected information for key multiple times: '(mod-path "zordoz"); values: '#(("REPL") (mod-path "zordoz") (2) (doc #"main" #"index.html") #f) '#(("API") (mod-path "zordoz") (3) (doc #"main" #"index.html") #f)
那么,有什么方法可以跨多个 scribble 文件记录这两个函数,即使它们是在同一模块中定义的?
如果这两个文件都作为另一个文件的子部分包含,比如 main.rkt
,您可以将 defproc
放入该文件,其他两个文件将使用它作为 defproc
和 defform
.
例如:
#lang scribble/manual
@title{Zordoz}
@defmodule[zordoz]
@include-section[repl.scrbl]
@include-section[api.scrbl]
在 scribble 中,我可以使用文件中的 defproc
and defform
to define the documentation for a function or macro. And then scribble uses the nearest defform
来确定 function/macro 定义在哪个模块中。
但是,有时将同一模块的文档分成多个涂鸦文件有时是有意义的。
(假设您希望 init
函数的文档位于 repl.scrbl
中,并且您希望 find
的文档位于 api.scrbl
中。但是两者它们在同一个模块中定义,比如 repl.rkt
.)
但是,当文档中有多个相同 defmodule
的证实时,Scribble 会抱怨:
WARNING: collected information for key multiple times: '(index-entry (mod-path "zordoz")); values: (list '("zordoz") (list (link-element (style "RktModLink" (list 'tt-chars #0=(list (css-addition '(collects #"scribble" #"racket.css")) (tex-addition '(collects #"scribble" #"racket.tex"))))) (cached-element (style "RktSym" (list 'tt-chars #0#)) "zordoz... (list '("zordoz") (list (link-element (style "RktModLink" (list 'tt-chars #0=(list (css-addition '(collects #"scribble" #"racket.css")) (tex-addition '(collects #"scribble" #"racket.tex"))))) (cached-element (style "RktSym" (list 'tt-chars #0#)) "zordoz...
WARNING: collected information for key multiple times: '(mod-path "zordoz"); values: '#(("REPL") (mod-path "zordoz") (2) (doc #"main" #"index.html") #f) '#(("API") (mod-path "zordoz") (3) (doc #"main" #"index.html") #f)
raco setup: rendering: <pkgs>/zordoz/scribblings/main.scrbl
WARNING: collected information for key multiple times: '(index-entry (mod-path "zordoz")); values: (list '("zordoz") (list (link-element (style "RktModLink" (list 'tt-chars #0=(list (css-addition '(collects #"scribble" #"racket.css")) (tex-addition '(collects #"scribble" #"racket.tex"))))) (cached-element (style "RktSym" (list 'tt-chars #0#)) "zordoz... (list '("zordoz") (list (link-element (style "RktModLink" (list 'tt-chars #0=(list (css-addition '(collects #"scribble" #"racket.css")) (tex-addition '(collects #"scribble" #"racket.tex"))))) (cached-element (style "RktSym" (list 'tt-chars #0#)) "zordoz...
WARNING: collected information for key multiple times: '(mod-path "zordoz"); values: '#(("REPL") (mod-path "zordoz") (2) (doc #"main" #"index.html") #f) '#(("API") (mod-path "zordoz") (3) (doc #"main" #"index.html") #f)
那么,有什么方法可以跨多个 scribble 文件记录这两个函数,即使它们是在同一模块中定义的?
如果这两个文件都作为另一个文件的子部分包含,比如 main.rkt
,您可以将 defproc
放入该文件,其他两个文件将使用它作为 defproc
和 defform
.
例如:
#lang scribble/manual
@title{Zordoz}
@defmodule[zordoz]
@include-section[repl.scrbl]
@include-section[api.scrbl]