diff --git a/.github/workflows/javadoc-publish.yml b/.github/workflows/javadoc-publish.yml index e283dc3..6283d07 100644 --- a/.github/workflows/javadoc-publish.yml +++ b/.github/workflows/javadoc-publish.yml @@ -7,7 +7,7 @@ on: jobs: build: - name: Build Javadocs + name: Build Javadocs and DocFX Site runs-on: ubuntu-latest @@ -21,17 +21,31 @@ jobs: java-version: 17 distribution: 'temurin' + - name: Install .NET SDK # required for DocFX as a .NET tool + uses: actions/setup-dotnet@v4 + + - name: Install DocFX Tool + run: dotnet tool install -g docfx + - name: Install dependencies and generate Javadocs run: mvn clean install -B -q -Dgpg.skip=true javadoc:javadoc javadoc:jar + - name: Build Documentation Site + run: docfx ./docs/docfx.json + + - name: Copy Javadocs to _site/api-docs + run: | + mkdir -p docs/_site/java-docs + mv -v target/reports/apidocs/* docs/_site/java-docs/ + # Upload the Javadocs as an artifact to be deployed - - name: Upload Javadocs Artifact + - name: Upload Artifact uses: actions/upload-pages-artifact@v3 with: - path: target/reports/apidocs + path: docs/_site deploy: - name: Deploy Javadocs to GitHub Pages + name: Deploy to GitHub Pages runs-on: ubuntu-latest needs: build diff --git a/docs/docfx.json b/docs/docfx.json new file mode 100644 index 0000000..046e561 --- /dev/null +++ b/docs/docfx.json @@ -0,0 +1,18 @@ +{ + "build": { + "globalMetadata": { + "_appLogoPath": "images/logo.png" + }, + "content": [ + { + "files": ["*.md", "**.md", "toc.yml"] + } + ], + "resource": [ + { + "files": ["images/*"] + } + ], + "dest": "_site" + } +} \ No newline at end of file diff --git a/docs/getting-started.md b/docs/getting-started.md new file mode 100644 index 0000000..bcbb7a0 --- /dev/null +++ b/docs/getting-started.md @@ -0,0 +1,76 @@ +# Quick Start + +Follow these few simple steps to add Mailtrap API functionality into your Java project. + +# Prerequisites + +Make sure your project uses JDK 11 or higher + +## Setup + +### 1. Add the library as a Maven/Gradle dependency +Maven dependency + +```xml + + + io.mailtrap + mailtrap-java + *latest-version* + +``` + +Gradle Groovy dependency + +```groovy +implementation 'io.mailtrap:mailtrap-java:*latest-version*' +``` + +Gradle Kotlin DSL dependency + +```kotlin +implementation("io.mailtrap:mailtrap-java:*latest-version*") +``` + +### 2. Register/login into Mailtrap account +Obtain API token to configure and use MailtrapClient + +### 3. Configuration and usage + +```java +import io.mailtrap.client.MailtrapClient; +import io.mailtrap.config.MailtrapConfig; +import io.mailtrap.factory.MailtrapClientFactory; +import io.mailtrap.model.request.emails.Address; +import io.mailtrap.model.request.emails.MailtrapMail; + +import java.util.List; + +public class Minimal { + + private static final String TOKEN = ""; + private static final String SENDER_EMAIL = "sender@domain.com"; + private static final String RECIPIENT_EMAIL = "recipient@domain.com"; + + public static void main(String[] args) { + final MailtrapConfig config = new MailtrapConfig.Builder() + .token(TOKEN) + .build(); + + final MailtrapClient client = MailtrapClientFactory.createMailtrapClient(config); + + final MailtrapMail mail = MailtrapMail.builder() + .from(new Address(SENDER_EMAIL)) + .to(List.of(new Address(RECIPIENT_EMAIL))) + .subject("Hello from Mailtrap Sending!") + .text("Welcome to Mailtrap!") + .build(); + + try { + System.out.println(client.send(mail)); + } catch (Exception e) { + System.out.println("Caught exception : " + e); + } + } +} +``` \ No newline at end of file diff --git a/docs/images/logo.png b/docs/images/logo.png new file mode 100644 index 0000000..82dbe29 Binary files /dev/null and b/docs/images/logo.png differ diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..e0d0f6d --- /dev/null +++ b/docs/index.md @@ -0,0 +1,18 @@ +--- +_layout: landing +--- +# Official Mailtrap Java Client + +Welcome to the documentation portal for the official Mailtrap Java client! + +This client allows you to quickly and easily integrate your Java application with Mailtrap API. + + +## Table of contents + +- [Getting Started](getting-started.md) - quick overview on how to integrate Mailtrap into your project +- [Usage Examples](usage-examples.md) +- [API Reference](javadocs.md) - Detailed API Reference + +## License +Licensed under the MIT License. \ No newline at end of file diff --git a/docs/javadocs.md b/docs/javadocs.md new file mode 100644 index 0000000..b59c986 --- /dev/null +++ b/docs/javadocs.md @@ -0,0 +1,3 @@ +# Detailed Java API Reference + +View the Java API Documentation. diff --git a/docs/toc.yml b/docs/toc.yml new file mode 100644 index 0000000..d39d59d --- /dev/null +++ b/docs/toc.yml @@ -0,0 +1,8 @@ +- name: Home + href: index.md +- name: Getting Started + href: getting-started.md +- name: Usage Examples + href: usage-examples.md +- name: API Reference + href: javadocs.md \ No newline at end of file diff --git a/docs/usage-examples.md b/docs/usage-examples.md new file mode 100644 index 0000000..2b60abf --- /dev/null +++ b/docs/usage-examples.md @@ -0,0 +1,3 @@ +# Detailed Usage Examples + +Code examples, that covers all possible APIs can be found here \ No newline at end of file diff --git a/pom.xml b/pom.xml index be10c15..a3f29fc 100644 --- a/pom.xml +++ b/pom.xml @@ -194,6 +194,22 @@ jar + + javadoc-xml + + javadoc + + + + + + + + + + target/site/apidocs + +