public void execute()

in doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java [93:129]


    public void execute(Sink sink, MacroRequest request) throws MacroExecutionException {
        String source = request.getSourceContent();
        Parser parser = request.getParser();

        section = getInt(request, "section", 0);
        fromDepth = getInt(request, "fromDepth", 0);
        toDepth = getInt(request, "toDepth", DEFAULT_DEPTH);

        if (fromDepth > toDepth) {
            return;
        }

        IndexEntry index = new IndexEntry("index");
        IndexingSink tocSink = new IndexingSink(index);

        try {
            parser.parse(new StringReader(source), tocSink);
        } catch (ParseException e) {
            throw new MacroExecutionException(e);
        }

        if (index.getChildEntries().size() > 0) {
            sink.list(getAttributesFromMap(request.getParameters()));

            int i = 1;

            for (IndexEntry sectionIndex : index.getChildEntries()) {
                if ((i == section) || (section == 0)) {
                    writeSubSectionN(sink, sectionIndex, 1);
                }

                i++;
            }

            sink.list_();
        }
    }