Page 1 of 3

Graphing similar-UML LUA - alpha 0.0.2 release

Posted: Thu Oct 21, 2010 10:06 am
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 3773 times

Re: Graphing similar-UML LUA

Posted: Fri Oct 22, 2010 9:58 am
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... :/

Re: Graphing similar-UML LUA - first alpha release

Posted: Fri Oct 22, 2010 4:17 pm
by bartoleo
first alpha release
look first post of topic

Re: Graphing similar-UML LUA - first alpha release

Posted: Mon Oct 25, 2010 9:12 am
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 : == ~= < <= > >=

Re: Graphing similar-UML LUA - first alpha release

Posted: Mon Oct 25, 2010 9:44 am
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.

Re: Graphing similar-UML LUA - first alpha release

Posted: Mon Oct 25, 2010 9:48 am
by bartoleo
I prefer spaces vs tabs because
space is the same on every system/editor
tabs are different
so...
thank you for testing

Re: Graphing similar-UML LUA - first alpha release

Posted: Mon Oct 25, 2010 10:12 am
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.

Re: Graphing similar-UML LUA - first alpha release

Posted: Mon Oct 25, 2010 10:18 am
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...

Re: Graphing similar-UML LUA - first alpha release

Posted: Mon Oct 25, 2010 10:35 am
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... :)

Re: Graphing similar-UML LUA - first alpha release

Posted: Mon Oct 25, 2010 11:08 am
by bartoleo
thank you...
yes I must add "configurable options" ...
I've added now -usetab for tab-indenting
now I'll look for luadoc