-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.py
65 lines (53 loc) · 1.8 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
def define_env(env):
@env.macro
def dependency_listing(name: str, version: str = None) -> str:
if version is None:
version = name
return """
<!-- prettier-ignore -->
=== "Maven"
```xml
<dependencies>
<dependency>
<groupId>org.incendo</groupId>
<artifactId>cloud-{name}</artifactId>
<version>{version}</version>
</dependency>
</dependencies>
```
=== "Gradle (Kotlin)"
```kotlin
implementation("org.incendo:cloud-{name}:{version}")
```
=== "Gradle (Groovy)"
```groovy
implementation 'org.incendo:cloud-{name}:{version}'
```
""".format(name=name, version=env.variables.version[version])
@env.macro
def javadoc(link: str, title: str = None, code: bool = True) -> str:
if title is None:
split = link.split("/")
title = split[len(split) - 1].replace(".html", "")
if link.startswith("<"):
link = link[1: len(link) - 1]
if code:
title = f'`{title}`'
return '[{title}](<{link}> "Click to open the JavaDoc")'.format(link=link, title=title)
@env.macro
def snippet(path: str, section: str = "snippet", title: str = None, indent = 0) -> str:
if title is None:
title = path
if title:
title = 'title="{title}"'.format(title = title)
if section is not None:
path = path + ":" + section
return ''.join((' ' * indent) + line for line in """
```java {title}
--8<-- "{path}"
```
""".format(path=path, title=title).splitlines(True))
@env.macro
def figure(path: str, caption: str) -> str:
return ("<figure markdown>![{caption}]({path})<figcaption>{caption}</figcaption></figure>"
.format(path = path, caption = caption))