erlide_eclipse icon indicating copy to clipboard operation
erlide_eclipse copied to clipboard

Generate documentation for function, data structure

Open theking-laptop opened this issue 10 years ago • 7 comments

I couldn't find the way to generate documentation for function with nightly erlide. So I think erlide will be better if when we select a function then generate doc for it by clicking context menu or hitting short-cut key. The generated doc should be simple and defined as template that we can configure later.

For example (from: http://www.erlang.se/doc/programming_rules.shtml#REF20875),

Function doc:

%%----------------------------------------------------------------------
%% Function: get_server_statistics/2
%% Purpose: Get various information from a process.
%% Args:   Option is normal|all.
%% Returns: A list of {Key, Value} 
%%     or {error, Reason} (if the process is dead)
%%----------------------------------------------------------------------
get_server_statistics(Option, Pid) when pid(Pid) ->
  ......

Data structures doc:

%%---------------------------------------------------------------------
%% Data Type: person
%% where:
%%    name: A string (default is undefined).
%%    age: An integer (default is undefined).
%%    phone: A list of integers (default is []).
%%    dict:     A dictionary containing various information about the person. 
%%       A {Key, Value} list (default is the empty list).
%%----------------------------------------------------------------------
-record(person, {name, age, phone = [], dict = []}).

I think this feature is very helpful, at least for me :) I think you can also create a context menu to create erlang header file, I have to create file with extension "*.hrl" and it's boring job.

I hope my suggestions are positive.

theking-laptop avatar Mar 15 '14 15:03 theking-laptop

+1

---- theking-laptop skrev ----

I couldn't find the way to generate documentation for function with nightly erlide. So I think erlide will be better if when we select a function then generate doc for it by clicking context menu or hitting short-cut key. The generated doc should be simple and defined as template that we can configure later.

For example, Function doc:

%%---------------------------------------------------------------------- %% Function: get_server_statistics/2 %% Purpose: Get various information from a process. %% Args: Option is normal|all. %% Returns: A list of {Key, Value} %% or {error, Reason} (if the process is dead) %%---------------------------------------------------------------------- get_server_statistics(Option, Pid) when pid(Pid) -> ......

Data structures doc:

%%--------------------------------------------------------------------- %% Data Type: person %% where: %% name: A string (default is undefined). %% age: An integer (default is undefined). %% phone: A list of integers (default is []). %% dict: A dictionary containing various information about the person. %% A {Key, Value} list (default is the empty list). %%---------------------------------------------------------------------- -record(person, {name, age, phone = [], dict = []}).

I think this feature is very helpful, at least for me :) I think you can also create a context menu to create erlang header file, I have to create file with extension "*.hrl" and it's boring job.

I hope my suggestions are positive.

— Reply to this email directly or view it on GitHub.

drapostolos avatar Mar 15 '14 16:03 drapostolos

Very good suggestion! I will look at it almost right away.

Please keep suggestions and bugs coming, it is the only way to know what people actually use and need. Otherwise I have to guess...

vladdu avatar Mar 15 '14 16:03 vladdu

https://www.assembla.com/spaces/erlide/tickets/1339 https://www.assembla.com/spaces/erlide/tickets/1340

vladdu avatar Mar 15 '14 16:03 vladdu

Would you think that the following ways to implement these features would work?

  • Context menu on forms should have an option Source->Generate Element Comment.
  • If you write -include("foo.hrl") and foo.hrl doesn't exist, there should be a quick fix to create it (Ctrl+1)
  • On the context menu for defines and record definitions there should be an option Source->Move Element to Header, so that you can have them in the module at first. The selection for which header will offer the option to create a new one.

vladdu avatar Mar 16 '14 09:03 vladdu

Yes, I think that way is very good. Plus: Short-cut key for Generate Element Comment.

theking-laptop avatar Mar 16 '14 12:03 theking-laptop

would be nice to write "%%-" and press ENTER button, above a function, to generate the Function doc.

Similar to how Java editor does when writing "/*" and pressing ENTER above a method (or class). Or when writing "/" inline and pressing ENTER.

drapostolos avatar May 02 '14 11:05 drapostolos

Good idea. Thanks!

vladdu avatar May 04 '14 10:05 vladdu