lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> So basically all that manual labor is unavoidable?

Not necessarily, as it depends on how badly you want it, although
*some* manual labor is still going to be required.

You most likely don't need to write the descriptions by hand, as you
can write a script to process all the descriptions from C/lua files.
For example, there is constants.lua file that has all the constants
you may want to include in auto-complete. Each of the IUP modules
includes *_open function that populates a table with all the methods a
particular module implements. For example, iuplua_draw.c includes the
following:

void iupluadraw_open(lua_State * L)
{
  struct luaL_Reg funcs[] = {
    { "DrawBegin", DrawBegin },
    { "DrawEnd", DrawEnd },
    { "DrawParentBackground", DrawParentBackground },
    { "DrawLine", DrawLine },
    { "DrawRectangle", DrawRectangle },
    { "DrawArc", DrawArc },
    { "DrawPolygon", DrawPolygon },
    { "DrawText", DrawText },
    { "DrawImage", DrawImage },
    { "DrawSetClipRect", DrawSetClipRect },
    { "DrawGetClipRect", DrawGetClipRect },
    { "DrawResetClip", DrawResetClip },
    { "DrawSelectRect", DrawSelectRect },
    { "DrawFocusRect", DrawFocusRect },
    { "DrawGetSize", DrawGetSize },
    { "DrawGetTextSize", DrawGetTextSize },
    { "DrawGetImageInfo", DrawGetImageInfo },
    { NULL, NULL },
  };

You can parse that description to extract all functions you're
interested in. You also should be able to extract its parameters (and
their names where available), but it's going to be more work.

I've done something very similar to populate API descriptions for one
of the C-based APIs in ZeroBraneStudio (see this old commit:
https://github.com/pkulchenko/ZeroBraneStudio/commit/185ebb5bbfca03ac1fefb4d57acfca31789e4bcb#diff-d7572116afa19d269e5ab4e33c8b01bd8789ed70eb033b7539d1283a48a90b5bR6696);
the advantage is that it only needs to be done once (assuming the
syntax stays the same), but there is still some initial work involved.

Paul.

On Wed, Oct 11, 2023 at 12:05 PM Илья Рахметов <raxmetov2003@gmail.com> wrote:
>
> So basically all that manual labor is unavoidable?
>
> ср, 11 окт. 2023 г. в 20:57, Antonio Scuri <antonio.scuri@gmail.com>:
>>
>>  IUP is self aware of its elements, their attributes and callbacks. But not values.
>>
>>  This means you can use IUP calls to get the list of elements, and a list of attributes and callbacks for each element. But not their values.
>>
>>  The IupVled and IupLuaScripter applications use those functions.
>>
>>   But I don't recall any diagrams, at least not any official ones.
>>
>> Best,
>> Scuri
>>
>>
>> Em qua., 11 de out. de 2023 às 12:39, Илья Рахметов <raxmetov2003@gmail.com> escreveu:
>>>
>>> I'm trying to create documentation for IUPLua to provide full Intellisense support with Lua language server for IUPLua users. I want to describe each element, each dialog and each attribute so users get autocompletion, spell checking and other features in their text editor while typing their code instead of consulting documentation in their browser.
>>>
>>> IUP consists of many elements which have many different attributes. Some attributes for different elements have the same name but can take different values (like "ALIGNMENT"). These values are present in the description in plain text which makes them easy to read but difficult to parse. Some elements inherit other elements which is also described as plain text making them as difficult to parse. Some elements (such as IupTree) have their attributes and callbacks described in separate documents. Some elements have restrictions on their attributes which is again described in plain text (for example, IupTree documentation contains this line: "Drag & Drop attributes and callbacks are supported, but SHOWDRAGDROP must be set to NO.").
>>>
>>> Resolving all these difficulties by hand not only would be time-consuming but could also lead to mistakes in generated files which would basically provide false documentation to the users. I also would like to be able to generate documentation for IUP 4.0 (which I hope is released sooner or later) the same way.
>>>
>>> Is there some kind of UML-like class diagram for IUP that would cover all relationships, callbacks, attributes and their possible values for each element and dialog that would allow parsing it to
>>> an abstract annotation system?