rust html source code browser generator, rust source code navigator, possible component for IDE ? Example output - see rust compiler source & std libs:-
Uses rust libsyntax to find symbol definitions
and generates HTML view of source with links
finds struct-defs, functions, methods, fields
writes ast node def info into '.rfx' files in plaintext.
Also spits out a graphviz dotfile with the static callgraph, modules as clusters.
"make" to compile and run test program
"make rustsrc" to generate HTML source for the main rust source tree at $(RUST_PATH)/src
./rustfind -h to display options
./rustfind cratename.rs sourcefile.rs:line:col
... compiles 'cratename.rs',then shows the
location&definition referenced by sourcefile:line:col
./rustfind -j cratename.rs -- dump spans & node definition links as JSON
./rustfind -w cratename.rs -- creates HTML view of sourcecode
roadmap
[1] a commandline tool rustfind sourcefile.rs:LINE:COLUMN: --> definition.rs:LINE:col
(to add add hoc navigation tools eg gedit external tools)
[.1] CTAGS generation ??
[.1] interactive commandline tool (enter src/location/symbol-> dump location)
[.2] possibly queries like "list all the functions that use this type, list all the impls' for this type.."
[.3] links to Rustdoc ?
[2] JSON / or other dump
.. are there any formats IDE's read for their indexers?
[3] options to dump/pretty print more context for the definitoon
[4] an html hyperlinked source generator, like woboq?
... + popup type annotaions?
[5] use components for IDE integration?
example of callgraph output
![Screenshot](screenshot/callgraph2.png)
Notes on sourcecode:-
--------------------
-find_ast_node contains the node scanning
-borrows code from rustdoc_ng
-there might be a fair amoount of repition with the compiler internals eg ast node wrappers,
this can be cleaned up..
-a lot here would factor out if ctxt had a node_id:span map
Other:-
-------
improved syntax highlighting rust.lang & required styles (for gtksourceview) included in scripts
more ideas
can ctags actually deal with overloaded symbols?
could we write out an intermediate that editors can read for fast jump-to-def, with some dynamic context ..
.rfx format:
------------
libname node_id source-file-name line col length kind [identifier]
jdef nodeid libname def_node_id
use the jump-to-def info to generate call graphs,
maybe generate dotfiles for graphviz to render these out,
some sort of static linked html callgraph which links back into the sourcecode would be nice..
perhaps generate views of static callgraphs for each module ? (collapse functions to modules to make the amount of information in each page manageable?)
info from wiki
<mark_edward> there was a recent PR merged, that meant that chars could no longer be used as integral types
<mark_edward> lemme find it...
<doomlord__> oh does that break ioutil.rs by any chance :)
<mark_edward> it breaks.. this: https://github.com/dobkeratops/rustfind/blob/master/htmlwriter.rs#L81
<doomlord__> ok, yikes.
<mark_edward> also something seems to have changed about .unwrap_or_default
<doomlord__> i vaguely remermber talk about that but can't remember what changed..
<doomlord__> it might just be renamed to .unwrap_or() ?
<doomlord__> i seem to remember some discussion about wanting symetry between or's /elses
<mark_edward> right, right, lemme check
<doomlord__> hopefully the char thing is just something changing to u8s perhaps..
<mark_edward> hopefully... maybe there is still a way to get chars to ints, lol
<doomlord__> in the name of safety it's sometimes surprising what you cant do ... but in that instance i think i'm ultimately just transfrering charcters from one buffer to another.. ither might even be a more direct function
<mark_edward> doomlord__: do you think this will do it: http://seld.be/rustdoc/master/std/char/fn.to_digit.html
<doomlord__> ah - i had to translate soemthing ,
<doomlord__> oh yeah now i remember - its translating various things for html .. "<" -> "<" etc etc
<doomlord__> so its not a straight copy
<mark_edward> hmmm...
<doomlord__> perhaps that could be a key:value map if they really dont want chars indexable.
<doomlord__> ^or if they really dont want to use chars as ints (indices)
<doomlord__> self.doc.push_str(self.xlat[x]); <<<< sorry for the crytpic ASM inspired name, ".xlat" is a translation table holding all that.
<doomlord__> so xlat:[str] could be changed to xlat:hashmap<char,str>
<mark_edward> you think that approach won't break too much else? and do hashmaps have [x] indexing?
<doomlord__> it would be changed to "self.doc.push_str(self.xlat.find(x).unwrap_or(""))" i think
<doomlord__> similarly building xlat would be .insert(...)
<mark_edward> okay..
<doomlord__> https://github.com/dobkeratops/rustfind/blob/master/htmlwriter.rs <<< mk_xlat_table
currently calls to methods on trait objects aren't handled;
in jumptodefmap.rs: fn lookup_def_node_of_node(../) , the match case for typeck::method_object(mp) is incomplete.. it probably needs to resolve these methods using its' method-index.. is there helper code in rust already for this ?
As a temporary fix It might be sufficient to just show the definition of the objects' trait - of course the exact impl' isn't inferable from a trait call... that would be better than nothing.
commandline functions or indexed html pages to search all the traits implemented for a particular type
this could look like generating similar information to a C++ header.. type { all the methods supported , listed in one place..}
beyond that listing all the functoins that take a particular type as a parameter would also be useful..
would generating lots of static HTML for navigation this way get out of hand?
check what rustdoc_ng does first, stick to features that complement what that already does.
Currently the html always looks for a .css file in the same directory as the html output.
it would be better if they all referenced this from the same place,
it doesn't even copy this .css file into the output directories yet.. i'd been doing that manually for testing. the fact it uses a .css at all is a bit of an afterthought
I am working on this now. I am a relative novice in this area of programming, so feel free to do it yourself if I'm taking too long or not being to competent.
From a cursory examination, i should be able to make the port however