Skip to content

Commit f772173

Browse files
committed
Improve docs generators
1 parent 9d9fdd1 commit f772173

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

docs/docs/en/basics/types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ OwnLang types are:
77
* Array - arrays
88
* Map - objects (an associative arrays)
99
* Function - functions
10+
* Class
1011

1112
Since OwnLang is dynamic programming language, which means that explicitly declare the types is not necessary.
1213

docs/docs/ru/basics/types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Array - массивы
88
* Map - объекты (ассоциативные массивы)
99
* Function - функции
10+
* Class - классы
1011

1112
Поскольку OwnLang - динамически типизируемый язык программирования, это значит, что явно объявлять типы не нужно.
1213

docs/src/docgen-md.own

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,7 @@ def writeFunctions(f, functions, lang, level = 2) {
136136
writeDescription(f, info, lang, " — %s")
137137
writeLine(f, "")
138138

139-
example = getValue(info, "example", lang)
140-
if (length(example ?? "")) {
141-
writeLine(f, "\n```own")
142-
writeLine(f, example)
143-
writeLine(f, "```")
144-
}
139+
writeExample(f, info, lang)
145140
}
146141
}
147142

@@ -155,6 +150,7 @@ def writeTypes(f, types, lang) {
155150
writeDescription(f, info, lang, "%s\n")
156151
writeFunctions(f, info.functions ?? [], lang, 4);
157152
writeLine(f, "")
153+
writeExample(f, info, lang)
158154
}
159155
}
160156

@@ -179,6 +175,15 @@ def writeSince(f, version, lang, isInline = false) {
179175
}
180176
}
181177

178+
def writeExample(f, info, lang) {
179+
example = getValue(info, "example", lang)
180+
if (length(example ?? "")) {
181+
writeLine(f, "\n```own")
182+
writeLine(f, example)
183+
writeLine(f, "```")
184+
}
185+
}
186+
182187
// -- utils
183188
def getValue(object, key, lang = "en") {
184189
newKey = (lang != "en") ? (key + "_" + lang) : key

docs/src/main/java/com/annimon/ownlang/docs/ModuleInfo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ public ModuleInfo(String name) {
2020
types = new ArrayList<>();
2121
}
2222

23+
public String name() {
24+
return name;
25+
}
26+
2327
public List<Map<String, Object>> functions() {
2428
return functions.stream().sorted()
2529
.map(f -> {
@@ -62,8 +66,8 @@ public List<Map<String, Object>> constants() {
6266
public Map<String, Object> info() {
6367
final Map<String, Object> result = new LinkedHashMap<>();
6468
result.put("name", name);
65-
result.put("scope", "both");
6669
result.put("since", "%d.%d.%d".formatted(Version.VERSION_MAJOR, Version.VERSION_MINOR, Version.VERSION_PATCH));
70+
result.put("scope", "both");
6771
result.put("constants", constants());
6872
result.put("functions", functions());
6973
if (!types.isEmpty()) {

docs/src/main/java/com/annimon/ownlang/docs/ModulesInfoCreator.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,16 @@ private static void printAsYaml(List<ModuleInfo> moduleInfos) {
4848
options.setIndent(2);
4949
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
5050

51-
final List<Map<String, Object>> infos = new ArrayList<>();
51+
final Yaml yaml = new Yaml(options);
5252
for (ModuleInfo moduleInfo : moduleInfos) {
53-
infos.add(moduleInfo.info());
53+
final String separator = "-".repeat(moduleInfo.name().length() + 12);
54+
System.out.println(separator);
55+
System.out.print("--- ");
56+
System.out.print(moduleInfo.name() + ".yml");
57+
System.out.println(" ---");
58+
System.out.println(separator);
59+
System.out.println(yaml.dump(moduleInfo.info()));
5460
}
55-
System.out.println(new Yaml(options).dump(infos));
5661
}
5762

5863
private static List<String> listValues(Class<?> moduleClass) {

docs/src/modules/server.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ types:
227227
desc: returns an User-Agent header
228228
desc_ru: возвращает заголовок User-Agent
229229
- name: Config
230-
desc: |-
230+
example: |-
231231
{
232232
"webjars": true,
233233
"classpathDirs": ["dir1", "dir2"],

0 commit comments

Comments
 (0)