With the current implementation of `scribble/lp2`, you could create a
"dummy.rkt" module

  #lang racket/base
  (define foo 'foo)
  (define bar 'bar)
  (provide (all-defined-out))

and use `(require (for-label "dummy.rkt"))` with
`@declare-exporting["dummy.rkt"]` to get hyperlinking.


But I imagine you'd rather not duplicate the definitions in a separate
file. I've adjusted `scribble/lp2` to create the `doc` submodule with
`module*` instead of `module`, so there's some change of referencing
the runnable module from the documentation module.

Still, `@(require (for-label "test.scrbl"))` won't work, because the
module is first expanded as-is, and then ex-expanded in a `doc`
submodule. I haven't yet found a good way of connecting the two. Here's
a hack to try for now:

 @(define-syntax (self-for-label stx)
    ;; Detect whether we've in the `doc` submodule:
    (if (list? (resolved-module-path-name
                (variable-reference->resolved-module-path
                 (#%variable-reference))))
        (syntax-local-introduce
         #`(begin
            (require (for-label (submod "..")))
            (declare-exporting #:use-sources
                               (,(car
                                  (resolved-module-path-name
                                   (variable-reference->resolved-module-path
                                    (#%variable-reference))))))))
        #'(void)))
 @(self-for-label)

If `foo` and `bar` are meant to be documented as coming from a
particular module, you'll probably want to through out the
`declare-exporting` part and include a direct `defmodule` declaration
in your document, instead.

At Tue, 29 Dec 2015 15:19:13 -0800, Matthew Butterick wrote:
> Bug or insurmountable limitation? In the sample scribble/lp2 file below, the 
> @racket[foo] reference at the end will *not* end up hyperlinked to the 
> documentation for `foo` above it. I infer this is because `foo` and `bar` are 
> treated as unbound identifiers.
> 
> If you add @(require (for-label "test.scrbl")) to the top, you get a 
> loading-cycle error.
> 
> 
> 
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;;; test.scrbl
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> #lang scribble/lp2
> @(require scribble/manual)
> 
> @title[#:style manual-doc-style]{test.scrbl}
> 
> @chunk[<*>
>   (provide foo bar)
>   (define (foo) 42)
>   (define (bar) (foo))]
> 
> @defproc[(foo) any/c] 
> 42.
> 
> @defproc[(bar) any/c] 
> Like @racket[foo].
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to