Skip to content

Commit 960fa69

Browse files
committed
Added DocFX to create API References site
1 parent 962f6a3 commit 960fa69

File tree

8 files changed

+154
-7
lines changed

8 files changed

+154
-7
lines changed

.github/workflows/javadoc-publish.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
build:
10-
name: Build Javadocs
10+
name: Build Javadocs and DocFX Site
1111

1212
runs-on: ubuntu-latest
1313

@@ -21,17 +21,25 @@ jobs:
2121
java-version: 17
2222
distribution: 'temurin'
2323

24+
- name: Install .NET SDK (required for DocFX as a .NET tool)
25+
uses: actions/setup-dotnet@v3
26+
with:
27+
dotnet-version: '7.x'
28+
29+
- name: Install DocFX Tool
30+
run: dotnet tool install -g docfx
31+
2432
- name: Install dependencies and generate Javadocs
2533
run: mvn clean install -B -q -Dgpg.skip=true javadoc:javadoc javadoc:jar
2634

27-
# Upload the Javadocs as an artifact to be deployed
28-
- name: Upload Javadocs Artifact
29-
uses: actions/upload-pages-artifact@v3
30-
with:
31-
path: target/reports/apidocs
35+
- name: Build Documentation Site
36+
run: docfx ./docs/docfx.json
37+
38+
- name: Copy Javadocs to _site/api-docs
39+
run: cp -r target/reports/apidocs/* docs/_site/java-docs/
3240

3341
deploy:
34-
name: Deploy Javadocs to GitHub Pages
42+
name: Deploy to GitHub Pages
3543

3644
runs-on: ubuntu-latest
3745
needs: build

docs/docfx.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"build": {
3+
"content": [
4+
{
5+
"files": ["*.md", "**.md", "toc.yml"]
6+
}
7+
],
8+
"resource": [
9+
{
10+
"files": ["images*"]
11+
}
12+
],
13+
"dest": "_site"
14+
}
15+
}

docs/getting-started.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Quick Start
2+
3+
Follow these few simple steps to add Mailtrap API functionality into your Java project.
4+
5+
# Prerequisites
6+
7+
Make sure your project uses JDK 11 or higher
8+
9+
## Setup
10+
11+
### 1. Add the library as a Maven/Gradle dependency
12+
Maven dependency
13+
14+
```xml
15+
16+
<dependency>
17+
<groupId>io.mailtrap</groupId>
18+
<artifactId>mailtrap-java</artifactId>
19+
<version>*latest-version*</version>
20+
</dependency>
21+
```
22+
23+
Gradle Groovy dependency
24+
25+
```groovy
26+
implementation 'io.mailtrap:mailtrap-java:*latest-version*'
27+
```
28+
29+
Gradle Kotlin DSL dependency
30+
31+
```kotlin
32+
implementation("io.mailtrap:mailtrap-java:*latest-version*")
33+
```
34+
35+
### 2. Register/login into Mailtrap account
36+
Obtain API token to configure and use MailtrapClient
37+
38+
### 3. Configuration and usage
39+
40+
```java
41+
import io.mailtrap.client.MailtrapClient;
42+
import io.mailtrap.config.MailtrapConfig;
43+
import io.mailtrap.factory.MailtrapClientFactory;
44+
import io.mailtrap.model.request.emails.Address;
45+
import io.mailtrap.model.request.emails.MailtrapMail;
46+
47+
import java.util.List;
48+
49+
public class Minimal {
50+
51+
private static final String TOKEN = "<YOUR MAILTRAP TOKEN>";
52+
private static final String SENDER_EMAIL = "[email protected]";
53+
private static final String RECIPIENT_EMAIL = "[email protected]";
54+
55+
public static void main(String[] args) {
56+
final MailtrapConfig config = new MailtrapConfig.Builder()
57+
.token(TOKEN)
58+
.build();
59+
60+
final MailtrapClient client = MailtrapClientFactory.createMailtrapClient(config);
61+
62+
final MailtrapMail mail = MailtrapMail.builder()
63+
.from(new Address(SENDER_EMAIL))
64+
.to(List.of(new Address(RECIPIENT_EMAIL)))
65+
.subject("Hello from Mailtrap Sending!")
66+
.text("Welcome to Mailtrap!")
67+
.build();
68+
69+
try {
70+
System.out.println(client.send(mail));
71+
} catch (Exception e) {
72+
System.out.println("Caught exception : " + e);
73+
}
74+
}
75+
}
76+
```

docs/index.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
_layout: landing
3+
---
4+
# Official Mailtrap Java Client
5+
6+
Welcome to the documentation portal for official Java client for <a href="https://mailtrap.io/" target="_blank">Mailtrap</a>!
7+
8+
This client allows you to quickly and easily integrate your Java application with Mailtrap API.
9+
10+
11+
## Table of contents
12+
13+
- [Getting Started](getting-started.md) - quick overview on how to integrate Mailtrap into your project
14+
- [Usage Examples](usage-examples.md)
15+
- [API Reference](javadocs.md) - Detailed API Reference
16+
17+
## License
18+
Licensed under the <a href="https://github.com/railsware/mailtrap-java/blob/main/LICENSE.txt" target="_blank">MIT License</a>.

docs/javadocs.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Detailed Java API Reference
2+
3+
View the <a href="./java-docs/index.html" target="_blank">Java API Documentation</a>.

docs/toc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- name: Home
2+
href: index.md
3+
- name: Getting Started
4+
href: getting-started.md
5+
- name: Usage Examples
6+
href: usage-examples.md
7+
- name: API Reference
8+
href: javadocs.md

docs/usage-examples.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Detailed Usage Examples
2+
3+
Code examples, that covers all possible APIs can be found <a href="https://github.com/railsware/mailtrap-java/tree/main/examples/java/io/mailtrap/examples" target="_blank">here</a>

pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,22 @@
194194
<goal>jar</goal>
195195
</goals>
196196
</execution>
197+
<execution>
198+
<id>javadoc-xml</id>
199+
<goals>
200+
<goal>javadoc</goal>
201+
</goals>
202+
<configuration>
203+
<additionalOptions>
204+
<option>-docletpath</option>
205+
<option>${java.home}/../lib/tools.jar</option>
206+
<option>-doclet</option>
207+
<option>com.sun.tools.javadoc.Main</option>
208+
<option>-xml</option>
209+
</additionalOptions>
210+
<outputDirectory>target/site/apidocs</outputDirectory>
211+
</configuration>
212+
</execution>
197213
</executions>
198214
</plugin>
199215

0 commit comments

Comments
 (0)