3

Is there a python or ruby library to create a code outline for the given code? The library should support multiple languages.

I am looking for something like outline view in Eclipse. I don't need the UI, and i can write my own. But I am looking for a library which parses the given language and creates an outline datastructure.

18bytes
  • 5,951
  • 7
  • 42
  • 69
  • 2
    Could you use question marks? :-) – Dr. Jan-Philip Gehrcke Sep 10 '12 at 17:36
  • see similar question http://stackoverflow.com/questions/260165/whats-the-best-way-to-generate-a-uml-diagram-from-python-source-code (not quite the same but close enough to give you a starting point) – Joran Beasley Sep 10 '12 at 17:42
  • @JoranBeasley: Not the best example, and certainly not cross-language. – Martijn Pieters Sep 10 '12 at 17:44
  • 1
    yeah but it at least steers him in the right general direction ... – Joran Beasley Sep 10 '12 at 17:46
  • I have no idea what a code outline is. Are you asking to generate UML? – Joshua Cheek Sep 10 '12 at 18:37
  • Code outline image: http://www.google.co.in/imgres?imgurl=http://www.jmesnil.net.s3.amazonaws.com/images/2009-08-14-eclipse-outline.png&imgrefurl=http://www.jmesnil.net/weblog/2009/08/14/nice-clojure-outline-in-textmate/&usg=__oBWqh5bSEPP_uzF3COsOzL5R0Zo=&h=437&w=332&sz=104&hl=en&start=1&sig2=OviYtZtF_qylLrwYQF639w&zoom=1&tbnid=kKEEtoOAK2A99M:&tbnh=126&tbnw=96&ei=yDROUK8YiPiYBZOsgJgP&um=1&itbs=1 – 18bytes Sep 10 '12 at 18:43

1 Answers1

1

As far as I know there is no such library. You could create it yourself though.

A pragmatic way would be to follow the indentation levels in Python. For other languages, you could either follow the indentation level, or use regular expression matching and a stack to keep track your outline.

Hans Then
  • 10,935
  • 3
  • 32
  • 51