Graphing similar-UML LUA - alpha 0.0.2 release

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
bartoleo
Party member
Posts: 118
Joined: Wed Jul 14, 2010 10:57 am
Location: Savigliano

Graphing similar-UML LUA - alpha 0.0.2 release

Post by bartoleo »

just looking for analysys... document ... reformat lua code
I worked on a little thing and I drawed my project as similar-uml
using lua and graphviz (http://www.graphviz.org/)

prject source on bitbucket: https://bitbucket.org/bartoleo/prettydoclua/overview

alpha 0.0.1 release
it's written in LUA (yeah!!!)
it needs lfs library (luafilesystem) http://keplerproject.github.com/luafilesystem/
and lpeg library http://www.inf.puc-rio.br/~roberto/lpeg/lpeg.html

it can reformat your .lua files in a dir and subdirs (for each .lua it createas a .lua.ind file with code reformatted)
it can write a file called <yourdir>/doc/graph.dot with a similar-UML of your LUA files (to render it you needs graphviz)

reformat:
reindent code
eliminate tabs :joker: (tabs are only allowed in tab-indenting with -usetab option)
eliminate 2 or more cr/lf
trim trailing blanks

can add luadoc skeleton comment if missing

usage:

Code: Select all

Usage: c:\temp\prettydoclua\prettifier.lua root_dir [options]
Reindent/reformat .lua files.
Adding LUADOC skeleton comment if missing. (with --luadoc)
Creating .dot (uml charting) in root_dir/doc if present (with --chart)
For each .lua file will create a .lua.ind file containg reformat/LUADOC
  Available options are:
  --usetab               use tabs for indenting (default is spaces)
  --spaces:N             to specify the number of spaces indenting (default:2)
  --indentblockcomment   enable indenting of block comments (comments
                         starting with --[[ (experimental)
  --chart                create .dot file in root_dir/doc if present
  --noreformat           disable indenting/reformatting
  --luadoc               adds luadoc skeleton comment/params if missing
  --lex                  for each .lua file creates a .lua.lex containg
                         info on code tokenized
  --help                 print this help and exit
  --version              print version information
special:
if you don't want to reformat any files in a dir you can put a file called ".do_not_autoreformat" in dir
or in code if you want to disable reformat you can add this comment:
--do_not_autoreformat
and to reenable reformat
--do_autoreformat

it's alpha so use it at your own risk (make backup of code before trying)
untested on linux/mac

next: better reformatting
and code analysys (boh... )
chart.png
chart.png (6.21 KiB) Viewed 3780 times
Attachments
prettydoclua.zip
(7.75 KiB) Downloaded 344 times
Last edited by bartoleo on Wed Oct 27, 2010 4:29 pm, edited 11 times in total.
Bartoleo
User avatar
arquivista
No longer with us
Posts: 266
Joined: Tue Jul 06, 2010 8:39 am
Location: Insert Geolocation tag here
Contact:

Re: Graphing similar-UML LUA

Post by arquivista »

bartoleo wrote:just looking for analysys... document ... reformat lua code
I worked on a little thing and I drawed my project as similar-uml
using lua and graphviz (http://www.graphviz.org/)
I'll try working more on it
( I'm thinking on indenting, adding comment for luadoc..)
Sorry but I skipped test this. Even the Mac version have a step by step install pkg procedement. Byeee... :/
--------------------------------------------------------
To Do: Insert Signature Here
--------------------------------------------------------
User avatar
bartoleo
Party member
Posts: 118
Joined: Wed Jul 14, 2010 10:57 am
Location: Savigliano

Re: Graphing similar-UML LUA - first alpha release

Post by bartoleo »

first alpha release
look first post of topic
Bartoleo
User avatar
bartoleo
Party member
Posts: 118
Joined: Wed Jul 14, 2010 10:57 am
Location: Savigliano

Re: Graphing similar-UML LUA - first alpha release

Post by bartoleo »

corrected problem with else and elseif (not indented correctly)
added format with only one space after "," and none before
added space before and after : == ~= < <= > >=
Bartoleo
User avatar
arquivista
No longer with us
Posts: 266
Joined: Tue Jul 06, 2010 8:39 am
Location: Insert Geolocation tag here
Contact:

Re: Graphing similar-UML LUA - first alpha release

Post by arquivista »

It generates the .ind files preserving the .lua ones right?

I tested in windows, wanted to do it in Mac but don't have it installed in OSX (and I'm totally noob in terminal).
Well prettify I don't know, but identing correctly it does. It seems replaces tabs with 2 spaces. Perhaps misses an option/switch to select indenting by tabs or spaces and how much spaces used. Nice work Bart.
--------------------------------------------------------
To Do: Insert Signature Here
--------------------------------------------------------
User avatar
bartoleo
Party member
Posts: 118
Joined: Wed Jul 14, 2010 10:57 am
Location: Savigliano

Re: Graphing similar-UML LUA - first alpha release

Post by bartoleo »

I prefer spaces vs tabs because
space is the same on every system/editor
tabs are different
so...
thank you for testing
Bartoleo
User avatar
arquivista
No longer with us
Posts: 266
Joined: Tue Jul 06, 2010 8:39 am
Location: Insert Geolocation tag here
Contact:

Re: Graphing similar-UML LUA - first alpha release

Post by arquivista »

bartoleo wrote:I prefer spaces vs tabs because
space is the same on every system/editor
tabs are different
so...
thank you for testing
ok, sorry then, I didn't realized that was a self-use project so forget -switches ideia for customizing. Anyway I leave you with this http://www.iovene.com/61, could someday help.
--------------------------------------------------------
To Do: Insert Signature Here
--------------------------------------------------------
User avatar
bartoleo
Party member
Posts: 118
Joined: Wed Jul 14, 2010 10:57 am
Location: Savigliano

Re: Graphing similar-UML LUA - first alpha release

Post by bartoleo »

no... i don't want to code a "self-use project"...
I always thought that tabs are evil..
but if someone wants it...
no problem
I'll work on it...
Bartoleo
User avatar
arquivista
No longer with us
Posts: 266
Joined: Tue Jul 06, 2010 8:39 am
Location: Insert Geolocation tag here
Contact:

Re: Graphing similar-UML LUA - first alpha release

Post by arquivista »

bartoleo wrote:no... i don't want to code a "self-use project"...
I always thought that tabs are evil..
but if someone wants it...
no problem
I'll work on it...
I don't know if anyone else wants it since till now no one more seems interested in your pro-LOVE meritorous project but I know that you for sure have proud and like of do things in the right way. So I only wanted to show that your tastes were that a kind "blinding" you. The correct way seems you to let things configurable and let people decide acording their tastes. As you see is not only the old coder boring tab/space evil fight but also things like the number of spaces used. Just trying to help you... :)
--------------------------------------------------------
To Do: Insert Signature Here
--------------------------------------------------------
User avatar
bartoleo
Party member
Posts: 118
Joined: Wed Jul 14, 2010 10:57 am
Location: Savigliano

Re: Graphing similar-UML LUA - first alpha release

Post by bartoleo »

thank you...
yes I must add "configurable options" ...
I've added now -usetab for tab-indenting
now I'll look for luadoc
Bartoleo
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests