Re: [racket-users] generating hyperlinks into Scribble docs

2015-04-19 Thread Matthew Butterick
Very close, thank you. The optional #:external-root-url argument turns it
into an external link.

#lang racket
(require setup/xref
 scribble/xref
 net/url)

(define (get-docs-url-string module-path export)
  (define xref (load-collections-xref))
  (define tag (xref-binding-definition-tag xref (list module-path export)
#f))
  (define-values (path url-tag) (xref-tag-path+anchor xref tag
#:external-root-url http://docs.racket-lang.org;))
  (format ~a#~a path url-tag))

(get-docs-url-string 'racket 'map)

 
http://docs.racket-lang.org/reference/pairs.html#(def._((lib._racket/private/map..rkt)._map))




On Sun, Apr 19, 2015 at 1:45 PM, Robby Findler ro...@eecs.northwestern.edu
wrote:

 Is this what you're after?

 Robby

 #lang racket
 (require setup/xref
  scribble/xref
  net/url)

 (define (get-docs-url module-path export)
   (define xref (load-collections-xref))
   (define tag (xref-binding-definition-tag xref (list module-path export)
 #f))
   (define-values (path url-tag) (xref-tag-path+anchor xref tag))
   (cond
 [path
  (define url (path-url path))
  (if tag
  (make-url (url-scheme url)
(url-user url)
(url-host url)
(url-port url)
(url-path-absolute? url)
(url-path url)
(url-query url)
url-tag)
  url)]
 [else #f]))

 (get-docs-url 'racket 'map)

 On Sun, Apr 19, 2015 at 2:10 PM, Matthew Butterick m...@mbtype.com wrote:
  This seems straightforward but I'm getting lost in the weeds: what's the
 simplest way to generate hyperlinks into Scribble docs on the web (without
 having to manually copy the URL)?
 
  For instance, the URL for `map` looks like this:
 
 
 http://docs.racket-lang.org/reference/pairs.html?q=map#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29
 
  So if I start with this:
 
  #lang racket
  (require scribble/manual)
  (unknown-function (racket map))
 
  What is the `unknown-function` I need to generate the URL above?
 
 


-- 
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.


Re: [racket-users] generating hyperlinks into Scribble docs

2015-04-19 Thread Robby Findler
Is this what you're after?

Robby

#lang racket
(require setup/xref
 scribble/xref
 net/url)

(define (get-docs-url module-path export)
  (define xref (load-collections-xref))
  (define tag (xref-binding-definition-tag xref (list module-path export) #f))
  (define-values (path url-tag) (xref-tag-path+anchor xref tag))
  (cond
[path
 (define url (path-url path))
 (if tag
 (make-url (url-scheme url)
   (url-user url)
   (url-host url)
   (url-port url)
   (url-path-absolute? url)
   (url-path url)
   (url-query url)
   url-tag)
 url)]
[else #f]))

(get-docs-url 'racket 'map)

On Sun, Apr 19, 2015 at 2:10 PM, Matthew Butterick m...@mbtype.com wrote:
 This seems straightforward but I'm getting lost in the weeds: what's the 
 simplest way to generate hyperlinks into Scribble docs on the web (without 
 having to manually copy the URL)?

 For instance, the URL for `map` looks like this:

 http://docs.racket-lang.org/reference/pairs.html?q=map#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29

 So if I start with this:

 #lang racket
 (require scribble/manual)
 (unknown-function (racket map))

 What is the `unknown-function` I need to generate the URL above?


 --
 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.