Items

[ Top ] [ ROBODoc ] [ Modules ]

FUNCTION

This module contains functions that deal with items. The documentation consists of headers, and headers contains one of more items. Each item has a name and a body. All possible items are listed in configuration.items. A uses can specify that certain items are not to be added to the documentation. These items are listed in configuration.ignore_items.

AUTHOR

Frans Slothouber


Is_Format_Item

[ Top ] [ HeaderTypes ] [ Functions ]

FUNCTION

Tells wether this item should be formatted by the browser

SYNPOPSIS

int Is_Format_Item(
    enum ItemType item_type )

INPUTS

item_type -- Type of item (also the index to the item name)

RESULT

TRUE -- Item should be formatted by the browser FALSE -- Item should be left alone

SOURCE

{
    unsigned int        i;

    /* Lookup if item should be formatted by the browser */
    for ( i = 0; i < configuration.format_items.number; ++i )
    {
        if ( !strcmp
             ( configuration.format_items.names[i],
               configuration.items.names[item_type] ) )
        {
            /* Item name match, it sould be formatted by the browser */
            return TRUE;
        }
    }

    /* Leave item alone */
    return FALSE;
}

Is_Preformatted_Item

[ Top ] [ HeaderTypes ] [ Functions ]

FUNCTION

Tells wether this item should be automatically preformatted in the output.

SYNPOPSIS

int Is_Preformatted_Item(
    enum ItemType item_type )

INPUTS

item_type -- Type of item (also the index to the item name)

RESULT

TRUE -- Item should be automatically preformatted FALSE -- Item should NOT be automatically preformatted

SOURCE

{
    unsigned int        i;

    /* Lookup if item should be preformatted */
    for ( i = 0; i < configuration.preformatted_items.number; ++i )
    {
        if ( !strcmp
             ( configuration.preformatted_items.names[i],
               configuration.items.names[item_type] ) )
        {
            /* Item name match, it sould be preformatted */
            return TRUE;
        }
    }

    /* Do not automatically preformat item */
    return FALSE;
}

item_name_buffer

[ Top ] [ Items ] [ Variables ]

FUNCTION

Stores the name of the last item that was found.

SOURCE

#define MAX_ITEM_NAME_LENGTH 1024
char                item_name_buffer[MAX_ITEM_NAME_LENGTH];

RB_Create_Item

[ Top ] [ Items ] [ Functions ]

SOURCE

struct RB_Item     *RB_Create_Item(
    enum ItemType arg_item_type )
{
    struct RB_Item     *item = malloc( sizeof( struct RB_Item ) );

    assert( item );

    item->next = 0;
    item->type = arg_item_type;
    item->begin_index = 0;
    item->end_index = 0;
    item->max_line_number = 0;

    return item;
}

RB_Get_Item_Type

[ Top ] [ Items ] [ Functions ]

FUNCTION

return the item_type represented by the given string.

SYNOPSIS

 *   int RB_Get_Item_Type( char *cmp_name )

INPUTS

char *cmp_name -- item_name to evaluate

RESULT

int -- the right item_type or NO_ITEM

SOURCE

int RB_Get_Item_Type(
    char *cmp_name )
{
    unsigned int        item_type;

    assert( configuration.items.number );
    for ( item_type = 0; item_type < configuration.items.number; ++item_type )
    {
        char               *item = configuration.items.names[item_type];

        /* Skip preformat mark */
        if ( *item == '-' )
            item++;
        if ( !strcmp( item, cmp_name ) )
        {
            return ( item_type );
        }
    }
    return ( NO_ITEM );
}

RB_Is_ItemName

[ Top ] [ Items ] [ Functions ]

FUNCTION

Is there an itemname in the line. Ignores leading spaces and remark markers.

INPUTS

line -- line to be searched.

RESULT

The kind of item that was found or NO_ITEM if no item could be found. The name of the item will be stored in item_name_buffer.

NOTES

We used to check for misspelled items names by testing if the item name buffer consists of only upper case characters. However checking for a misspelled item name this way results in many false positives. For instance many warnings are given for FORTRAN code as all the keywords are in uppercase. We need to find a better method for this.

SOURCE

enum ItemType RB_Is_ItemName(
    char *line )
{
    char               *cur_char = line;
    int                 i = 0;

    cur_char = RB_Skip_Whitespace( cur_char );
    if ( RB_Has_Remark_Marker( cur_char ) )
    {
        cur_char = RB_Skip_Remark_Marker( cur_char );
        cur_char = RB_Skip_Whitespace( cur_char );
        /* It there anything left? */
        if ( strlen( cur_char ) )
        {
            enum ItemType       item_type = NO_ITEM;

            /* Copy the name */
            strcpy( item_name_buffer, cur_char );
            /* remove any trailing spaces */
            for ( i = strlen( item_name_buffer ) - 1;
                  i >= 0 && utf8_isspace( item_name_buffer[i] ); --i )
            {
                item_name_buffer[i] = '\0';
            }
            /* No check and see if this is an item name */
            if ( strlen( item_name_buffer ) )
            {
                item_type = RB_Get_Item_Type( item_name_buffer );
#if 0                           /* Until we find a better method */
                if ( item_type == NO_ITEM )
                {
                    /* Check if it is a misspelled item name */
                    item_type = POSSIBLE_ITEM;
                    for ( i = 0; i < strlen( item_name_buffer ); ++i )
                    {
                        if ( !( utf8_isupper( item_name_buffer[i] ) ||
                                utf8_isspace( item_name_buffer[i] ) ) )
                        {
                            /* No it is not */
                            item_type = NO_ITEM;
                            break;
                        }
                    }
                }
#endif
            }
            return item_type;
        }
        else
        {
            return NO_ITEM;
        }
    }
    else
    {
        return NO_ITEM;
    }
}

Works_Like_SourceItem

[ Top ] [ HeaderTypes ] [ Functions ]

FUNCTION

Tells wether this item works similar to the source item, that is weather it copies it's content verbatim to the output document.

SYNPOPSIS

int Works_Like_SourceItem(
    enum ItemType item_type )

INPUTS

item_type -- Type of item (also the index to the item name)

RESULT

TRUE -- Item works like a SOURCE item FALSE -- Item does NOT work like a SOURCE item

SOURCE

{
    unsigned int        i;

    /* Check if it is a SOURCE item */
    if ( item_type == SOURCECODE_ITEM )
    {
        return TRUE;
    }

    /* Lookup if it works like a SOURCE item */
    for ( i = 0; i < configuration.source_items.number; ++i )
    {
        if ( !strcmp
             ( configuration.source_items.names[i],
               configuration.items.names[item_type] ) )
        {
            return TRUE;
        }
    }

    /* Neither SOURCE item, nor works like it */
    return FALSE;
}