Skip to content

Commit

Permalink
Move "org.asciidoctor.ast" package to "asciidoctorj-api" project
Browse files Browse the repository at this point in the history
* convert classes to interfaces in api project
** Author
** ContentPart
** DocumentHeader
** RevisionInfo
** StructuredDocument
* Create implementation in core project
  • Loading branch information
jmini authored and robertpanzer committed Nov 30, 2017
1 parent 5c0e5d3 commit fe43931
Show file tree
Hide file tree
Showing 41 changed files with 331 additions and 174 deletions.
15 changes: 15 additions & 0 deletions asciidoctorj-api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apply plugin: 'osgi'

dependencies {
}


jar {
manifest {
symbolicName = 'org.asciidoctor'
instruction 'Export-Package',
"org.asciidoctor.ast;version=\"${version}\""
}
}


2 changes: 2 additions & 0 deletions asciidoctorj-api/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
properName=AsciidoctorJ API
description=API for AsciidoctorJ
16 changes: 16 additions & 0 deletions asciidoctorj-api/src/main/java/org/asciidoctor/ast/Author.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.asciidoctor.ast;

public interface Author {

String getFullName();

String getLastName();

String getFirstName();

String getMiddleName();

String getEmail();

String getInitials();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.asciidoctor.ast;

import java.util.List;
import java.util.Map;

public interface ContentPart {

String getId();

int getLevel();

String getContext();

String getStyle();

String getRole();

String getTitle();

Map<String, Object> getAttributes();

String getContent();

List<? extends ContentPart> getParts();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public interface DescriptionList extends StructuralNode {
boolean hasItems();

@Deprecated
public String render();
String render();

public String convert();
String convert();

}
Original file line number Diff line number Diff line change
@@ -1,80 +1,61 @@
package org.asciidoctor.ast;

import java.util.List;
import java.util.Map;

public interface Document extends StructuralNode {

/**
* @return The Title structure for this document.
* @see Title
*/
Title getStructuredDoctitle();

/**
* @return The title as a String.
* @see Title
*/
String getDoctitle();

/**
* @deprecated Please use {@link #getDoctitle()}
* @return The title as a String.
* @see Title
*/
String doctitle();

/**
*
* @return page title
*/
String title();

/**
*
* @return attributes defined in document
*/
Map<String, Object> getAttributes();

/**
* @return basebackend attribute value
*/
boolean isBasebackend(String backend);

/**
* @deprecated Please use {@link #isBasebackend(String)}
* @return basebackend attribute value
*/
boolean basebackend(String backend);

/**
*
* @return blocks contained within current Document.
*/
List<StructuralNode> blocks();

/**
*
* @return options defined in document.
*/
Map<Object, Object> getOptions();

/**
* Gets the current counter with the given name and increases its value.
* At the first invocation the counter will return 1.
* After the call the value of the counter is set to the returned value plus 1.
* @param name
* @return
*/
int getAndIncrementCounter(String name);

/**
* Gets the current counter with the given name and increases its value.
* At the first invocation the counter will return the given initial value.
* After the call the value of the counter is set to the returned value plus 1.
* @param name
* @param initialValue
* @return
*/
int getAndIncrementCounter(String name, int initialValue);
}
package org.asciidoctor.ast;

import java.util.Map;

public interface Document extends StructuralNode {

/**
* @return The Title structure for this document.
* @see Title
*/
Title getStructuredDoctitle();

/**
* @return The title as a String.
* @see Title
*/
String getDoctitle();

/**
* @deprecated Please use {@link #getDoctitle()}
* @return The title as a String.
* @see Title
*/
String doctitle();

/**
* @return basebackend attribute value
*/
boolean isBasebackend(String backend);

/**
* @deprecated Please use {@link #isBasebackend(String)}
* @return basebackend attribute value
*/
boolean basebackend(String backend);

/**
*
* @return options defined in document.
*/
Map<Object, Object> getOptions();

/**
* Gets the current counter with the given name and increases its value.
* At the first invocation the counter will return 1.
* After the call the value of the counter is set to the returned value plus 1.
* @param name
* @return
*/
int getAndIncrementCounter(String name);

/**
* Gets the current counter with the given name and increases its value.
* At the first invocation the counter will return the given initial value.
* After the call the value of the counter is set to the returned value plus 1.
* @param name
* @param initialValue
* @return
*/
int getAndIncrementCounter(String name, int initialValue);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.asciidoctor.ast;

import java.util.List;
import java.util.Map;

public interface DocumentHeader {

List<? extends Author> getAuthors();

Title getDocumentTitle();

String getPageTitle();

Author getAuthor();

RevisionInfo getRevisionInfo();

Map<String, Object> getAttributes();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public interface List extends StructuralNode {
boolean hasItems();

@Deprecated
public String render();
String render();

public String convert();
String convert();

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

public interface ListItem extends StructuralNode {

public String getMarker();
String getMarker();

/**
* @return The text of the cell including substitutions being applied.
*/
public String getText();
String getText();

/**
* @return The text of the cell without substitutions being applied.
*/
public String getSource();
String getSource();

/**
* Sets the source of the ListItem.
* @param source The source of this ListItem, substitutions will still be applied.
*/
public void setSource(String source);
void setSource(String source);

public boolean hasText();
boolean hasText();
}
15 changes: 15 additions & 0 deletions asciidoctorj-api/src/main/java/org/asciidoctor/ast/PhraseNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.asciidoctor.ast;

public interface PhraseNode extends ContentNode {

@Deprecated
String render();

String convert();

String getType();

String getText();

String getTarget();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.asciidoctor.ast;

public interface RevisionInfo {

String getDate();

String getNumber();

String getRemark();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

public interface Row {

public List<Cell> getCells();
List<Cell> getCells();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package org.asciidoctor.ast;

import java.util.List;

/**
* Structure document containing header and content chunks
*
* @author marek
*
*/
public interface StructuredDocument {

List<? extends ContentPart> getParts();

DocumentHeader getHeader();

/**
* Return first matched part by id
*
* @param id The id to match
* @return The ContentPart if the id is not null and the document
* contains a block-level element with this id or null otherwise.
*/
ContentPart getPartById(String id);

/**
* Return first matched part by style
*
* @param style The style to match
* @return The first ContentPart if the style is not null and the document
* contains a block-level element with this style name or null otherwise.
*/
ContentPart getPartByStyle(String style);

/**
* Return first matched part by role
*
* @param role The role to match
* @return The first ContentPart if the role is not null and the document
* contains a block-level element with this role name or null otherwise.
*/
ContentPart getPartByRole(String role);

/**
* Return all parts that match specified context
*
* @param context The context to match
* @return A list of ContentPart items that match the context if the
* context is not null or an empty collection.
*/
List<? extends ContentPart> getPartsByContext(String context);

/**
* Return all parts that match specified style
*
* @param style The style to match
* @return A list of ContentPart items that match the style if the
* style is not null or an empty collection.
*/
List<? extends ContentPart> getPartsByStyle(String style);

/**
* Return all parts that match specified role
*
* @param role The role to match
* @return A list of ContentPart items that match the role if the
* role is not null or an empty collection.
*/
List<? extends ContentPart> getPartsByRole(String role);
}
1 change: 1 addition & 0 deletions asciidoctorj-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apply plugin: 'osgi'

dependencies {
compile project(path: ':asciidoctorj-api')
compile "org.jruby:jruby:$jrubyVersion"
compile "com.beust:jcommander:$jcommanderVersion"
gems "rubygems:asciidoctor:$asciidoctorGemVersion"
Expand Down
Loading

0 comments on commit fe43931

Please sign in to comment.