Skip to content

Commit 95ca00e

Browse files
authored
XML Attrs Documentation / Generator (halfhp#41)
* initial implimentation of the xml attrs documentation generator with basic documentation. * more xml attr documentation.
1 parent 271438c commit 95ca00e

7 files changed

Lines changed: 1297 additions & 57 deletions

File tree

androidplot-core/build.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,42 @@ apply plugin: 'com.jfrog.bintray'
2020
apply plugin: 'com.vanniktech.android.junit.jacoco'
2121
apply plugin: 'com.github.kt3k.coveralls'
2222

23+
class AttrMarkdown extends DefaultTask {
24+
25+
def inFile
26+
def outFile
27+
28+
@TaskAction
29+
def generate() {
30+
def input = project.file(inFile)
31+
32+
def output = project.file(outFile)
33+
if(output.exists()) {
34+
output.delete()
35+
}
36+
output.parentFile.mkdirs()
37+
38+
input.text.findAll(/<!--\n?([\s\S]*?)\n?-->/) { match, g1 -> g1
39+
if(!g1.startsWith("NODOC")) {
40+
output.append(g1)
41+
output.append "\n\n"
42+
}
43+
}
44+
}
45+
}
46+
47+
/**
48+
* Generates xml attrs markdown docs. To run:
49+
* at the command line from the project root dir type:
50+
* ./gradlew generateAttrsMarkdown
51+
*
52+
* The generated doc will appear in / replace androidplot/docs/attrs.md
53+
*/
54+
task generateAttrsMarkdown(type: AttrMarkdown) {
55+
inFile = { "src/main/res/values/attrs.xml"}
56+
outFile = { "../docs/attrs.md" }
57+
}
58+
2359
android {
2460
compileSdkVersion theCompileSdkVersion
2561
buildToolsVersion theBuildToolsVersion

androidplot-core/src/main/java/com/androidplot/util/AttrUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private static Number getIntFloatDimenValue(TypedArray attrs, int valueAttr, Num
237237
} else if (valueType == TypedValue.TYPE_FLOAT) {
238238
result = attrs.getFloat(valueAttr, defaultValue.floatValue());
239239
} else {
240-
throw new IllegalArgumentException("Invalid value type - must be float or dimension.");
240+
throw new IllegalArgumentException("Invalid value type - must be int, float or dimension.");
241241
}
242242
}
243243
return result;

0 commit comments

Comments
 (0)