Skip to content

Commit fb785dc

Browse files
committed
XDOC: document required fields in generated docs
1 parent d8a240f commit fb785dc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

modello-plugins/modello-plugin-xdoc/src/main/java/org/codehaus/modello/plugin/xdoc/XdocGenerator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ private void writeFieldsTable(XMLWriter w, List<ModelField> fields, boolean elem
417417

418418
w.writeMarkup(getDescription(f));
419419

420+
if (f.isRequired()) {
421+
w.writeMarkup("<p><strong>Required</strong>: Yes.</p>");
422+
}
423+
420424
// Write the default value, if it exists.
421425
// But only for fields that are not a ModelAssociation
422426
if (f.getDefaultValue() != null && !(f instanceof ModelAssociation)) {

modello-plugins/modello-plugin-xdoc/src/test/java/org/codehaus/modello/plugin/xdoc/XdocGeneratorTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ private void checkMavenXdocGenerator() throws Exception {
135135

136136
// verify( "org.codehaus.modello.generator.xml.cdoc.XdocVerifier", "xdoc" );
137137
checkInternalLinks("maven.xml");
138+
139+
String content = FileUtils.fileRead(new File(getOutputDirectory(), "maven.xml"), "UTF-8");
140+
141+
Pattern requiredModelVersion =
142+
Pattern.compile("<code>modelVersion</code>.*?<strong>Required</strong>: Yes\\.", Pattern.DOTALL);
143+
assertTrue(requiredModelVersion.matcher(content).find(), "Required modelVersion field should be documented");
144+
145+
Pattern requiredGroupId =
146+
Pattern.compile("<code>groupId</code>.*?<strong>Required</strong>: Yes\\.", Pattern.DOTALL);
147+
assertTrue(requiredGroupId.matcher(content).find(), "Required groupId field should be documented");
138148
}
139149

140150
public void checkFeaturesXdocGenerator() throws Exception {

0 commit comments

Comments
 (0)