如何 Link 到程序的 Scribble 文档中的别名?

How to Link to an Alias in Scribble Documentation for a Procedure?

在为一个函数编写 Scribble 文档时,我想 link 一个内置函数,该函数与同一个 Scribble 文件中记录的另一个函数同名。通常是@racketlink is usable for this purpose (together with something like prefix-in to differentiate the two functions in the document namespace), but this doesn't appear to work when the link needs to be within the arguments section of a @defproc形式。例如:

@defproc[(my-proc [f procedure? b:compose])
         any/c]{

 A procedure similar to @racketlink[b:compose]{compose}.

}

注意上面b:compose的两个用法。后者 link 到 b:compose 简单地呈现为 compose (正如预期的那样)但是如果我在前一个实例中尝试相同的代码(在参数块中),它呈现为 (racketlink b:compose "compose") . "escape" 如何对 defproc 参数块中的内容进行字面处理?这与Scribble的"content"和"pre-content"概念以及"decoding"的过程有什么关系吗?

@racket[_]@defproc[_] 等形式让您可以使用 #,(读作 unsyntax)来避免 代码排版 语境。所以你应该能够把你的例子写成

@defproc[(my-proc [f procedure? #, @racketlink[b:compose]{compose})
         any/c]{ .... }

注意 #,@ 之间的 space,需要防止 reader 将整个序列读取为 unsyntax-splicing。由于 @ reader 与 reader 缩写如 #,.

相互作用的方式,您也可以将组合写成 @#,

将前内容(或前流等)转换为内容(或流等)的解码步骤无关。参见 the docs for scribble/decode