Code Monkey home page Code Monkey logo

rustfind's Introduction

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

rustfind's People

Contributors

am0d avatar dobkeratops avatar markjr94 avatar bonoboslookbook avatar kimundi avatar srgom avatar

Stargazers

 avatar ZQ avatar Faris Sufyan avatar Jiachen Zhang avatar  avatar Jesse Wright avatar  avatar Sean Jensen-Grey avatar  avatar Kumarajiva avatar shyan avatar Dan Connolly avatar V avatar Yaskhan avatar Cristi Burcă avatar Mikhail Malinin avatar Valerii Hiora avatar  avatar Markus Siemens avatar Ömer Sinan Ağacan avatar Ty Overby avatar  avatar  avatar Sean Gillespie avatar Radek Szymczyszyn avatar Joe Fredette avatar L W avatar Val Markovic avatar Andréy Lesnikóv avatar Daniel Fagnan avatar KokaKiwi avatar  avatar Keli avatar  avatar  avatar nielsle avatar Vasilis Kalintiris avatar David Yu avatar Pawel Barcik avatar Vijay Korapaty avatar itdaniher avatar Sam Nardoni avatar Brian Anderson avatar Jonas Hermsmeier avatar redaready avatar Howard Mao avatar Graydon Hoare avatar

Watchers

David Yu avatar James Cloos avatar  avatar

rustfind's Issues

display Type Information

very handy with deep expressions and type inference .. the ideal would be if in the html view there was a popup showing type info.

a first step would be to have some way of querying type , not just 'jump to definition'.

Needs license

This project really needs a license to define what everyone's rights are when working with the source and output.

generate call graphs

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?)

char can't be used as integral type anymore

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

links to rustdoc

would be nice to have links to rustdoc entries, and make it easy for those to link back to this source..

handle trait object method calls

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.

trait/impl/fn search/indexing

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.

Use valid html5 tags

The HTML output of rustfind includes many different tags which are not valid html5, e.g. <ln>, <maintext>, <bg15>, <c..> for many cs, etc.

These should all be cleaned up so that the source uses semantic html5 tags instead.

copy CSS files into subdirectories, or reference one main one

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

Port from removed syntax::oldvisit::, to syntax::visit

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.