Skip to content

Commit 8926cd9

Browse files
authored
Merge pull request #20 from railsware/feature/docfx-api-reference
Added DocFX to create API References site
2 parents 962f6a3 + eec9ee2 commit 8926cd9

File tree

9 files changed

+160
-4
lines changed

9 files changed

+160
-4
lines changed

.github/workflows/javadoc-publish.yml

Lines changed: 18 additions & 4 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,31 @@ 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@v4
26+
27+
- name: Install DocFX Tool
28+
run: dotnet tool install -g docfx
29+
2430
- name: Install dependencies and generate Javadocs
2531
run: mvn clean install -B -q -Dgpg.skip=true javadoc:javadoc javadoc:jar
2632

33+
- name: Build Documentation Site
34+
run: docfx ./docs/docfx.json
35+
36+
- name: Copy Javadocs to _site/api-docs
37+
run: |
38+
mkdir -p docs/_site/java-docs
39+
mv -v target/reports/apidocs/* docs/_site/java-docs/
40+
2741
# Upload the Javadocs as an artifact to be deployed
28-
- name: Upload Javadocs Artifact
42+
- name: Upload Artifact
2943
uses: actions/upload-pages-artifact@v3
3044
with:
31-
path: target/reports/apidocs
45+
path: docs/_site
3246

3347
deploy:
34-
name: Deploy Javadocs to GitHub Pages
48+
name: Deploy to GitHub Pages
3549

3650
runs-on: ubuntu-latest
3751
needs: build

docs/docfx.json

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

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/images/logo.png

3.51 KB
Loading

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 the official <a href="https://mailtrap.io/" target="_blank">Mailtrap</a> Java client!
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)