Java Code Examples for org.asciidoctor.ast.Document#setAttribute()

The following examples show how to use org.asciidoctor.ast.Document#setAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OverviewDocument.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
@Override
public Document apply(Document document, Parameters parameters) {
    Info apiInfo = parameters.openAPI.getInfo();
    document.setAttribute("openapi", parameters.openAPI.getOpenapi(), true);
    addDocumentTitle(document, apiInfo);
    addAuthorInfo(document, apiInfo);
    addVersionInfo(document, apiInfo);

    applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_BEFORE, document));
    Document subDocument = new DocumentImpl(document);
    Section overviewDoc = new SectionImpl(subDocument, "section", new HashMap<>(), new ArrayList<>(),
            null, new ArrayList<>(), 1, "", new ArrayList<>(),
            null, null, "", "", false, false);
    applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_BEGIN, subDocument));
    overviewDoc.setTitle(labels.getLabel(SECTION_TITLE_OVERVIEW));

    appendDescription(overviewDoc, apiInfo.getDescription());
    appendTermsOfServiceInfo(overviewDoc, apiInfo);
    appendLicenseInfo(overviewDoc, apiInfo);
    subDocument.append(overviewDoc);
    applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_END, subDocument));
    document.append(subDocument);

    externalDocumentationComponent.apply(document, parameters.openAPI.getExternalDocs());
    tagsComponent.apply(document, parameters.openAPI.getTags());
    applyOverviewDocumentExtension(new Context(OverviewDocumentExtension.Position.DOCUMENT_AFTER, document));
    return document;
}
 
Example 2
Source File: OverviewDocument.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
private void addAuthorInfo(Document rootDocument, Info info) {
    Contact contact = info.getContact();
    if (null != contact) {
        String author = Optional.ofNullable(contact.getName()).orElse("");
        String email = contact.getEmail();
        if (StringUtils.isNotBlank(email)) {
            rootDocument.setAttribute("email", email, true);
        }
        rootDocument.setAttribute("author", author, true);
        rootDocument.setAttribute("authorcount", 1L, true);
    }
}
 
Example 3
Source File: OverviewDocument.java    From swagger2markup with Apache License 2.0 4 votes vote down vote up
private void addVersionInfo(Document rootDocument, Info info) {
    String version = info.getVersion();
    if (StringUtils.isNotBlank(version)) {
        rootDocument.setAttribute("revnumber", version, true);
    }
}