I used scribble to generate my package's document.
And raco will integate my douments with racket self's documents, and add a searchbox on the topleft of the page.
You can see that when you use "raco docs".
Now I want use scribble as a document tool to generate my independent documents.
But when I use scribble --htmls demo.scribble, it can't have a searchbox ont the topleft of the page.
How to add the searchbox to let my document have the capability of search?
There is a way to do this, but sadly, it's not currently particularly pleasant. If you want us to make it better, please submit an issue (or I guess pull request if you're feeling ambitious) on how you would like to be able to do this. (Also if it does get improved, someone please update this answer.)
Sadly, you cannot render a scribble page with a search box using the
scribble
command line app (nor usingraco scribble
). Rather, you need to use scribble'srender
function, with thehtml-render-mixin
to render your document. Once you get over the hump of writing your own script to render your document though, it's fairly straightforward.The class produced by
html-render-mixin
has an (undocumented as of Racket 6.5, I will add documentation for Racket 6.6) field:search-box?
, that defaults to#f
. You could build your own renderer mixin that extends the html one, except changes the search box to #t. You can do that like so:From there, you can pass this into the render function directly with the render-mixin keyword argument:
Here,
webpage.scrbl
is the source for your file andwebpage.html
is your target location. They are lists so you can render multiple files at the same time.The
doc
variable is coming from thewebpage.scrbl
. (For reference, scribble files, when compiled, define a variable calleddoc
, which contains the content of your document.)Also, make sure that
webpage.scrbl
is written in thescribble/manual
language:#lang scribble/manual
, otherwise you may not get a search box there.When you run this file,
webpage.html
is generated with a search box. When you type into it and hit enter, it will go tosearch/index.html
in that same folder, passing in your search query as an http parameter. As far as I can tell, Racket currently doesn't export how it builds the internal search index, but you can find how it does it in:pkgs/racket-index/scribblings/main/search.scrbl
in the source code of the repo. If you would like that search page to come with scribble, please open an issue on github.