Beispiel #1
0
static void findTxt2tagsTags (void)
{
	NestingLevels *nls = nestingLevelsNew();
	vString *name = vStringNew();
	const unsigned char *line;

	while ((line = fileReadLine()) != NULL)
	{
		int depth;

		if (isTxt2tagsLine(line))
			; /* skip not to improperly match titles */
		else if (parseTxt2tagsTitle(line, name, &depth))
		{
			NestingLevel *nl = nestingLevelsGetCurrent(nls);
			while (nl && nl->indentation >= depth)
			{
				nestingLevelsPop(nls);
				nl = nestingLevelsGetCurrent(nls);
			}

			vStringTerminate(name);
			makeTxt2tagsTag(name, nls, K_SECTION);
			nestingLevelsPush(nls, name, K_SECTION);
			nestingLevelsGetCurrent(nls)->indentation = depth;
		}
	}
	vStringDelete (name);
	nestingLevelsFree(nls);
}
Beispiel #2
0
/*
* Emits a tag for the given 'name' of kind 'kind' at the current nesting.
*/
static void emitRubyTag (vString* name, rubyKind kind)
{
	tagEntryInfo tag;
	vString* scope;
	tagEntryInfo *parent;
	rubyKind parent_kind = K_UNDEFINED;
	NestingLevel *lvl;
	const char *unqualified_name;
	const char *qualified_name;
	int r;

        if (!RubyKinds[kind].enabled) {
            return;
        }

	vStringTerminate (name);
	scope = nestingLevelsToScope (nesting);
	lvl = nestingLevelsGetCurrent (nesting);
	parent = getEntryOfNestingLevel (lvl);
	if (parent)
		parent_kind =  parent->kind - RubyKinds;

	qualified_name = vStringValue (name);
	unqualified_name = strrchr (qualified_name, SCOPE_SEPARATOR);
	if (unqualified_name && unqualified_name[1])
	{
		if (unqualified_name > qualified_name)
		{
			if (vStringLength (scope) > 0)
				vStringPut (scope, SCOPE_SEPARATOR);
			vStringNCatS (scope, qualified_name,
			              unqualified_name - qualified_name);
			/* assume module parent type for a lack of a better option */
			parent_kind = K_MODULE;
		}
		unqualified_name++;
	}
	else
		unqualified_name = qualified_name;

	initTagEntry (&tag, unqualified_name, &(RubyKinds [kind]));
	if (vStringLength (scope) > 0) {
		Assert (0 <= parent_kind &&
		        (size_t) parent_kind < (ARRAY_SIZE (RubyKinds)));

		tag.extensionFields.scopeKind = &(RubyKinds [parent_kind]);
		tag.extensionFields.scopeName = vStringValue (scope);
	}
	r = makeTagEntry (&tag);

	nestingLevelsPush (nesting, r);

	vStringClear (name);
	vStringDelete (scope);
}
Beispiel #3
0
static void enterUnnamedScope (void)
{
	int r = CORK_NIL;
	NestingLevel *parent = nestingLevelsGetCurrent (nesting);
	tagEntryInfo *e_parent = getEntryOfNestingLevel (parent);

	if (e_parent)
	{
		tagEntryInfo e;
		initTagEntry (&e, "", e_parent->kind);
		e.placeholder = 1;
		r = makeTagEntry (&e);
	}
	nestingLevelsPush (nesting, r);
}
Beispiel #4
0
static void makeAsciidocTag (const vString* const name, const int kind)
{
	const NestingLevel *const nl = getNestingLevel(kind);

	if (vStringLength (name) > 0)
	{
		tagEntryInfo e;
		initTagEntry (&e, vStringValue (name), &(AsciidocKinds [kind]));

		e.lineNumber--;	/* we want the line before the '---' underline chars */

		if (nl && nl->type < kind)
		{
			e.extensionFields.scopeKind = &(AsciidocKinds [nl->type]);
			e.extensionFields.scopeName = vStringValue (nl->name);
		}
		makeTagEntry (&e);
	}
	nestingLevelsPush(nestingLevels, name, kind);
}
Beispiel #5
0
static void makeRstTag(const vString* const name, const int kind, const fpos_t filepos)
{
    const NestingLevel *const nl = getNestingLevel(kind);

    if (vStringLength (name) > 0)
    {
        tagEntryInfo e;
        initTagEntry (&e, vStringValue (name), &(RstKinds [kind]));

        e.lineNumber--;	/* we want the line before the '---' underline chars */
        e.filePosition = filepos;

        if (nl && nl->kindIndex < kind)
        {
            e.extensionFields.scopeKind = &(RstKinds [nl->kindIndex]);
            e.extensionFields.scopeName = vStringValue (nl->name);
        }
        makeTagEntry (&e);
    }
    nestingLevelsPush(nestingLevels, name, kind);
}