From 7373483ceed72974bd4ef0cb8b51a4bcadbbe3a6 Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Fri, 16 Feb 2024 09:38:16 +0000 Subject: [PATCH 1/5] Google Java Format --- .../at4j/core/exceptions/AzureException.java | 6 +- .../AzureExceptionInstantiation.java | 5 +- .../core/exceptions/BadRequestException.java | 5 +- .../core/exceptions/ForbiddenException.java | 5 +- .../InternalServerErrorException.java | 5 +- .../exceptions/MethodNotAllowedException.java | 5 +- .../core/exceptions/NotFoundException.java | 5 +- .../exceptions/RequestTimeoutException.java | 5 +- .../ServiceUnavailableException.java | 5 +- .../exceptions/UnauthorizedException.java | 5 +- .../UnsupportedMediaTypeException.java | 5 +- .../at4j/data/TranslationResult.java | 1 - .../data/request/DetectLanguageParams.java | 3 +- .../at4j/data/request/TranslateParams.java | 3 +- .../at4j/data/response/DetectResponse.java | 75 +++++++++---------- .../at4j/util/rest/RestRequest.java | 4 +- .../at4j/util/rest/RestRequestHandler.java | 1 - .../rest/RestRequestHttpResponseCode.java | 5 +- .../rest/RestRequestResponseInfoImpl.java | 3 +- .../at4j/util/rest/RestRequestResult.java | 3 +- .../util/rest/RestRequestResultErrorCode.java | 5 +- .../AzureExceptionInstantiationTest.java | 3 +- .../core/exceptions/AzureExceptionTest.java | 3 +- .../request/DetectLanguageParamsTest.java | 4 +- .../data/request/TranslateParamsTest.java | 4 +- 25 files changed, 63 insertions(+), 110 deletions(-) diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/AzureException.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/AzureException.java index 40ae61e..b111be0 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/AzureException.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/AzureException.java @@ -18,6 +18,7 @@ public class AzureException extends Exception { * request. */ private final transient RestRequestResponseInfo response; + /** * Creates a new instance of this class. * @@ -27,10 +28,7 @@ public class AzureException extends Exception { * @param response The information about the response. */ public AzureException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { super(message, origin); this.request = request; this.response = response; diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionInstantiation.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionInstantiation.java index 69d82ed..a4ba939 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionInstantiation.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionInstantiation.java @@ -22,8 +22,5 @@ public interface AzureExceptionInstantiation { * @return The new instance. */ T createInstance( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response); + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response); } diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/BadRequestException.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/BadRequestException.java index c37ca33..47c850c 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/BadRequestException.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/BadRequestException.java @@ -15,10 +15,7 @@ public class BadRequestException extends AzureException { * @param response The information about the response. */ public BadRequestException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { super(origin, message, request, response); } } diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/ForbiddenException.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/ForbiddenException.java index bd07b77..de46adc 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/ForbiddenException.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/ForbiddenException.java @@ -15,10 +15,7 @@ public class ForbiddenException extends AzureException { * @param response The information about the response. */ public ForbiddenException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { super(origin, message, request, response); } } diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/InternalServerErrorException.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/InternalServerErrorException.java index cad9835..1e3f729 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/InternalServerErrorException.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/InternalServerErrorException.java @@ -15,10 +15,7 @@ public class InternalServerErrorException extends AzureException { * @param response The information about the response. */ public InternalServerErrorException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { super(origin, message, request, response); } } diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/MethodNotAllowedException.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/MethodNotAllowedException.java index a9a42e7..c359120 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/MethodNotAllowedException.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/MethodNotAllowedException.java @@ -15,10 +15,7 @@ public class MethodNotAllowedException extends AzureException { * @param response The information about the response. */ public MethodNotAllowedException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { super(origin, message, request, response); } } diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/NotFoundException.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/NotFoundException.java index 3e91110..d4c3d8e 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/NotFoundException.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/NotFoundException.java @@ -15,10 +15,7 @@ public class NotFoundException extends BadRequestException { * @param response The information about the response. */ public NotFoundException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { super(origin, message, request, response); } } diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/RequestTimeoutException.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/RequestTimeoutException.java index de8727b..9bc32da 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/RequestTimeoutException.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/RequestTimeoutException.java @@ -15,10 +15,7 @@ public class RequestTimeoutException extends AzureException { * @param response The information about the response. */ public RequestTimeoutException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { super(origin, message, request, response); } } diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/ServiceUnavailableException.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/ServiceUnavailableException.java index d9cd480..b2983cd 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/ServiceUnavailableException.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/ServiceUnavailableException.java @@ -15,10 +15,7 @@ public class ServiceUnavailableException extends AzureException { * @param response The information about the response. */ public ServiceUnavailableException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { super(origin, message, request, response); } } diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/UnauthorizedException.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/UnauthorizedException.java index 51741e6..62937e2 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/UnauthorizedException.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/UnauthorizedException.java @@ -15,10 +15,7 @@ public class UnauthorizedException extends AzureException { * @param response The information about the response. */ public UnauthorizedException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { super(origin, message, request, response); } } diff --git a/src/main/java/io/github/brenoepics/at4j/core/exceptions/UnsupportedMediaTypeException.java b/src/main/java/io/github/brenoepics/at4j/core/exceptions/UnsupportedMediaTypeException.java index 023d972..ce6acae 100644 --- a/src/main/java/io/github/brenoepics/at4j/core/exceptions/UnsupportedMediaTypeException.java +++ b/src/main/java/io/github/brenoepics/at4j/core/exceptions/UnsupportedMediaTypeException.java @@ -15,10 +15,7 @@ public class UnsupportedMediaTypeException extends AzureException { * @param response The information about the response. */ public UnsupportedMediaTypeException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { super(origin, message, request, response); } } diff --git a/src/main/java/io/github/brenoepics/at4j/data/TranslationResult.java b/src/main/java/io/github/brenoepics/at4j/data/TranslationResult.java index 0f15150..a22107d 100644 --- a/src/main/java/io/github/brenoepics/at4j/data/TranslationResult.java +++ b/src/main/java/io/github/brenoepics/at4j/data/TranslationResult.java @@ -1,6 +1,5 @@ package io.github.brenoepics.at4j.data; - import java.util.Collection; import java.util.Optional; diff --git a/src/main/java/io/github/brenoepics/at4j/data/request/DetectLanguageParams.java b/src/main/java/io/github/brenoepics/at4j/data/request/DetectLanguageParams.java index 6d1b832..fd115db 100644 --- a/src/main/java/io/github/brenoepics/at4j/data/request/DetectLanguageParams.java +++ b/src/main/java/io/github/brenoepics/at4j/data/request/DetectLanguageParams.java @@ -88,8 +88,7 @@ public ArrayNode getBody() { * response is null, or the JSON body is null, or the JSON body does not contain a field * 'language' */ - public Optional handleResponse( - RestRequestResult response) { + public Optional handleResponse(RestRequestResult response) { if (response.getJsonBody().isNull() || response.getJsonBody().isEmpty()) return Optional.empty(); JsonNode jsonBody = response.getJsonBody(); diff --git a/src/main/java/io/github/brenoepics/at4j/data/request/TranslateParams.java b/src/main/java/io/github/brenoepics/at4j/data/request/TranslateParams.java index 9450b1f..d72ede8 100644 --- a/src/main/java/io/github/brenoepics/at4j/data/request/TranslateParams.java +++ b/src/main/java/io/github/brenoepics/at4j/data/request/TranslateParams.java @@ -346,8 +346,7 @@ public JsonNode getBody() { * response is null, or the JSON body is null, or the JSON body does not contain a field * 'translations'. */ - public Optional handleResponse( - RestRequestResult response) { + public Optional handleResponse(RestRequestResult response) { if (response.getJsonBody().isNull() || response.getJsonBody().isEmpty()) return Optional.empty(); JsonNode jsonBody = response.getJsonBody(); diff --git a/src/main/java/io/github/brenoepics/at4j/data/response/DetectResponse.java b/src/main/java/io/github/brenoepics/at4j/data/response/DetectResponse.java index d9d9dd0..b8df129 100644 --- a/src/main/java/io/github/brenoepics/at4j/data/response/DetectResponse.java +++ b/src/main/java/io/github/brenoepics/at4j/data/response/DetectResponse.java @@ -6,44 +6,43 @@ import java.util.List; /** - * This class represents a response from a language detection operation. - * It contains a list of detected languages. + * This class represents a response from a language detection operation. It contains a list of + * detected languages. */ public class DetectResponse { - // List to store the detected languages - private final List detectedLanguages; - - /** - * Constructor for DetectResponse. - * Initializes the list of detected languages. - */ - public DetectResponse() { - this.detectedLanguages = new ArrayList<>(); - } - - /** - * Adds a detected language to the list. - * @param detectedLanguage The detected language to be added. - */ - public void addDetectedLanguage(DetectedLanguage detectedLanguage) { - detectedLanguages.add(detectedLanguage); - } - - /** - * Returns the list of detected languages. - * @return A list of detected languages. - */ - public List getDetectedLanguages() { - return detectedLanguages; - } - - /** - * Returns the first detected language from the list. - * @return The first detected language. - */ - public DetectedLanguage getFirst() { - return detectedLanguages.get(0); - } - -} \ No newline at end of file + // List to store the detected languages + private final List detectedLanguages; + + /** Constructor for DetectResponse. Initializes the list of detected languages. */ + public DetectResponse() { + this.detectedLanguages = new ArrayList<>(); + } + + /** + * Adds a detected language to the list. + * + * @param detectedLanguage The detected language to be added. + */ + public void addDetectedLanguage(DetectedLanguage detectedLanguage) { + detectedLanguages.add(detectedLanguage); + } + + /** + * Returns the list of detected languages. + * + * @return A list of detected languages. + */ + public List getDetectedLanguages() { + return detectedLanguages; + } + + /** + * Returns the first detected language from the list. + * + * @return The first detected language. + */ + public DetectedLanguage getFirst() { + return detectedLanguages.get(0); + } +} diff --git a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequest.java b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequest.java index 3b036b8..8d5c2c8 100644 --- a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequest.java +++ b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequest.java @@ -131,7 +131,7 @@ public Exception getOrigin() { /** * Adds a query parameter to the url. * - * @param key The key of the parameter. + * @param key The key of the parameter. * @param value The value of the parameter. */ public void addQueryParameter(String key, String value) { @@ -150,7 +150,7 @@ public void addQueryParameters(Map parameters) { /** * Adds a header to the request. * - * @param name The name of the header. + * @param name The name of the header. * @param value The value of the header. */ public void addHeader(String name, String value) { diff --git a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestHandler.java b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestHandler.java index 13619fb..764a1ba 100644 --- a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestHandler.java +++ b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestHandler.java @@ -3,7 +3,6 @@ /** * This class is responsible for handling REST requests. It stores the result of a REST request, the * current request being processed, and the timestamp of the response. - * */ public class RestRequestHandler { // The result of the REST request diff --git a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestHttpResponseCode.java b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestHttpResponseCode.java index 62e9b70..1ffa254 100644 --- a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestHttpResponseCode.java +++ b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestHttpResponseCode.java @@ -232,10 +232,7 @@ public String getMeaning() { * @return The azure exception to throw for this kind of result code. */ public Optional getAzureException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { return Optional.ofNullable(azureExceptionInstantiation) .map(instantiator -> instantiator.createInstance(origin, message, request, response)); } diff --git a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResponseInfoImpl.java b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResponseInfoImpl.java index 91351c5..071ceb1 100644 --- a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResponseInfoImpl.java +++ b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResponseInfoImpl.java @@ -15,8 +15,7 @@ public class RestRequestResponseInfoImpl implements RestRequestResponseInfo { * @param request The request which this response answered. * @param restRequestResult The result of the response. */ - public RestRequestResponseInfoImpl( - RestRequestInfo request, RestRequestResult restRequestResult) { + public RestRequestResponseInfoImpl(RestRequestInfo request, RestRequestResult restRequestResult) { this.request = request; this.restRequestResult = restRequestResult; } diff --git a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResult.java b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResult.java index 7b9e247..8f28f26 100644 --- a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResult.java +++ b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResult.java @@ -28,8 +28,7 @@ public class RestRequestResult { * @param response The response of the RestRequest. * @throws IOException Passed on from {@link HttpResponse#body()}. */ - public RestRequestResult(RestRequest request, HttpResponse response) - throws IOException { + public RestRequestResult(RestRequest request, HttpResponse response) throws IOException { this.request = request; this.response = response; this.stringBody = response.body(); diff --git a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResultErrorCode.java b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResultErrorCode.java index 71dfa1c..d58ac75 100644 --- a/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResultErrorCode.java +++ b/src/main/java/io/github/brenoepics/at4j/util/rest/RestRequestResultErrorCode.java @@ -329,10 +329,7 @@ public RestRequestHttpResponseCode getResponseCode() { * @return The azure exception to throw for this kind of result code. */ public Optional getAzureException( - Exception origin, - String message, - RestRequestInfo request, - RestRequestResponseInfo response) { + Exception origin, String message, RestRequestInfo request, RestRequestResponseInfo response) { return Optional.ofNullable(azureExceptionInstantiation) .map(instantiate -> instantiate.createInstance(origin, message, request, response)) .filter( diff --git a/src/test/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionInstantiationTest.java b/src/test/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionInstantiationTest.java index 4c5e8df..a950873 100644 --- a/src/test/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionInstantiationTest.java +++ b/src/test/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionInstantiationTest.java @@ -11,8 +11,7 @@ class AzureExceptionInstantiationTest { private final Exception origin = new Exception(); private final RestRequestInfo request = Mockito.mock(RestRequestInfo.class); - private final RestRequestResponseInfo response = - Mockito.mock(RestRequestResponseInfo.class); + private final RestRequestResponseInfo response = Mockito.mock(RestRequestResponseInfo.class); private final AzureExceptionInstantiation azureExceptionInstantiation = AzureException::new; diff --git a/src/test/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionTest.java b/src/test/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionTest.java index 9169614..5950209 100644 --- a/src/test/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionTest.java +++ b/src/test/java/io/github/brenoepics/at4j/core/exceptions/AzureExceptionTest.java @@ -49,8 +49,7 @@ void requestInformationIsRetained() { @Test void responseInformationIsRetained() { - RestRequestResponseInfo response = - new RestRequestResponseInfoImpl(request, result); + RestRequestResponseInfo response = new RestRequestResponseInfoImpl(request, result); AzureException exception = new AzureException(null, null, null, response); assertEquals(Optional.of(response), exception.getResponse()); diff --git a/src/test/java/io/github/brenoepics/at4j/data/request/DetectLanguageParamsTest.java b/src/test/java/io/github/brenoepics/at4j/data/request/DetectLanguageParamsTest.java index ceff230..46daa87 100644 --- a/src/test/java/io/github/brenoepics/at4j/data/request/DetectLanguageParamsTest.java +++ b/src/test/java/io/github/brenoepics/at4j/data/request/DetectLanguageParamsTest.java @@ -73,7 +73,7 @@ void shouldReturnNullBodyWhenNoTextsAreAdded() { DetectLanguageParams params = new DetectLanguageParams(new ArrayList<>()); assertNull(params.getBody()); } - + @Test void shouldHandleResponseWithEmptyJsonBody() { DetectLanguageParams params = new DetectLanguageParams("Hello"); @@ -103,4 +103,4 @@ void shouldHandleResponseWithValidJsonBody() { assertTrue(result.isPresent()); } -} \ No newline at end of file +} diff --git a/src/test/java/io/github/brenoepics/at4j/data/request/TranslateParamsTest.java b/src/test/java/io/github/brenoepics/at4j/data/request/TranslateParamsTest.java index af7fc90..632dc0e 100644 --- a/src/test/java/io/github/brenoepics/at4j/data/request/TranslateParamsTest.java +++ b/src/test/java/io/github/brenoepics/at4j/data/request/TranslateParamsTest.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; import io.github.brenoepics.at4j.azure.lang.Language; import io.github.brenoepics.at4j.azure.lang.LanguageDirection; import io.github.brenoepics.at4j.data.Translation; @@ -260,7 +259,8 @@ void shouldHandleJsonBodyNullTranslations() { void shouldHandleJsonBodyWithValidTranslations() throws JsonProcessingException { TranslateParams params = new TranslateParams("Hello", List.of("fr")); String json = - "[{\"detectedLanguage\":{\"language\":\"en\",\"score\":0.98},\"translations\":[{\"text\":\"Olá, mundo\",\"to\":\"pt\"}]}]"; + "[{\"detectedLanguage\":{\"language\":\"en\",\"score\":0.98},\"translations\":[{\"text\":\"Olá," + + " mundo\",\"to\":\"pt\"}]}]"; RestRequestResult mockResponse = mock(RestRequestResult.class); ObjectMapper mapper = new ObjectMapper(); JsonNode mockJsonBody = mapper.readTree(json); From 87958a0bc23ae1b50193327efa0ef4612e53ebbb Mon Sep 17 00:00:00 2001 From: Breno A Date: Mon, 19 Feb 2024 20:56:07 -0300 Subject: [PATCH 2/5] bump: update config.ts --- docs/.vitepress/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index c404836..43d4ea6 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -2,7 +2,7 @@ import { defineConfigWithTheme, DefaultTheme } from 'vitepress' import { replaceTextPlugin } from './replaceTextPlugin' import { AT4J_VERSION, AT4JRelease } from './repository' import baseConfig from 'vitepress-carbon/config' -import type { ThemeConfig } from 'vitepress-carbon/config' +import type { ThemeConfig } from 'vitepress-carbon' const REPO_VERSION: string = await AT4J_VERSION() From 67efccef6895a535d6917c0d431b52e14d41a54f Mon Sep 17 00:00:00 2001 From: BrenoEpic Date: Mon, 19 Feb 2024 22:41:56 -0300 Subject: [PATCH 3/5] docs: fix new theme --- docs/.vitepress/{config.ts => config.mts} | 43 +------ docs/.vitepress/github/Author.ts | 20 ---- docs/.vitepress/github/Release.ts | 23 ---- docs/.vitepress/replaceTextPlugin.ts | 10 -- docs/.vitepress/repository.ts | 29 ----- docs/.vitepress/theme/index.ts | 5 +- docs/.vitepress/theme/override.css | 0 docs/env.d.ts | 8 +- docs/package.json | 14 +-- docs/src/about/team.md | 10 -- docs/src/about/team/Member.ts | 26 ----- docs/src/about/team/TeamList.vue | 105 ------------------ docs/src/about/team/TeamPage.vue | 35 ------ docs/src/about/team/members.json | 10 -- .../{errors.data.ts => errors.data.mts} | 0 docs/src/error-reference/index.md | 2 +- docs/src/examples/index.md | 2 +- docs/src/guide/azure-subscription.md | 7 +- docs/src/guide/basic-usage.md | 14 ++- docs/tsconfig.json | 4 +- 20 files changed, 35 insertions(+), 332 deletions(-) rename docs/.vitepress/{config.ts => config.mts} (55%) delete mode 100644 docs/.vitepress/github/Author.ts delete mode 100644 docs/.vitepress/github/Release.ts delete mode 100644 docs/.vitepress/replaceTextPlugin.ts delete mode 100644 docs/.vitepress/repository.ts create mode 100644 docs/.vitepress/theme/override.css delete mode 100644 docs/src/about/team.md delete mode 100644 docs/src/about/team/Member.ts delete mode 100644 docs/src/about/team/TeamList.vue delete mode 100644 docs/src/about/team/TeamPage.vue delete mode 100644 docs/src/about/team/members.json rename docs/src/error-reference/{errors.data.ts => errors.data.mts} (100%) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.mts similarity index 55% rename from docs/.vitepress/config.ts rename to docs/.vitepress/config.mts index 43d4ea6..887e882 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.mts @@ -1,12 +1,8 @@ -import { defineConfigWithTheme, DefaultTheme } from 'vitepress' -import { replaceTextPlugin } from './replaceTextPlugin' -import { AT4J_VERSION, AT4JRelease } from './repository' -import baseConfig from 'vitepress-carbon/config' +import { defineConfigWithTheme } from 'vitepress' import type { ThemeConfig } from 'vitepress-carbon' +import baseConfig from 'vitepress-carbon/config' -const REPO_VERSION: string = await AT4J_VERSION() - -const nav: DefaultTheme.NavItem[] = [ +const nav = [ { text: 'Docs', activeMatch: `^/(guide|examples)/`, @@ -22,24 +18,12 @@ const nav: DefaultTheme.NavItem[] = [ activeMatch: `^/about/`, items: [ { text: 'FAQ', link: '/about/faq' }, - { text: 'Team', link: '/about/team' }, { text: 'Releases', link: '/about/releases' }, { text: 'Code of Conduct', link: '/about/coc' } ] }, - { - text: `Latest Release: ${REPO_VERSION}`, - items: [ - { - text: 'GitHub Release', - link: AT4JRelease?.html_url ? AT4JRelease.html_url : 'https://github.com/brenoepics/at4j/releases' - }, - { text: 'Maven Central', link: 'https://mvnrepository.com/artifact/io.github.brenoepics/at4j/latest' } - ] - } ] - -export const sidebar = { +const sidebar = { '/guide/': [ { text: 'Getting Started', @@ -85,6 +69,7 @@ export const sidebar = { ] } +// https://vitepress.dev/reference/site-config export default defineConfigWithTheme({ extends: baseConfig, lang: 'en-US', @@ -120,7 +105,7 @@ export default defineConfigWithTheme({ socialLinks: [ { icon: { - svg: 'Postman' + svg: '' }, link: 'https://www.postman.com/maintenance-astronaut-2993290/workspace/brenoepics/collection/18589822-dfe7a640-9b94-47a8-b19f-46cb9cc8843e?action=share&creator=18589822' }, @@ -137,20 +122,4 @@ export default defineConfigWithTheme({ message: 'Apache 2.0 Licensed' } }, - - markdown: { - config(md) { - md.use(replaceTextPlugin, 'AT4J-VERSION', REPO_VERSION) - } - }, - - vite: { - build: { - minify: 'terser', - chunkSizeWarningLimit: Infinity - }, - json: { - stringify: true - } - } }) diff --git a/docs/.vitepress/github/Author.ts b/docs/.vitepress/github/Author.ts deleted file mode 100644 index 739a219..0000000 --- a/docs/.vitepress/github/Author.ts +++ /dev/null @@ -1,20 +0,0 @@ -export interface Author { - login: string - id: number - node_id: string - avatar_url: string - gravatar_id: string - url: string - html_url: string - followers_url: string - following_url: string - gists_url: string - starred_url: string - subscriptions_url: string - organizations_url: string - repos_url: string - events_url: string - received_events_url: string - type: string - site_admin: boolean -} diff --git a/docs/.vitepress/github/Release.ts b/docs/.vitepress/github/Release.ts deleted file mode 100644 index d7ea736..0000000 --- a/docs/.vitepress/github/Release.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { Author } from './Author' - -export interface Release { - url: string - assets_url: string - upload_url: string - html_url: string - id: number - author: Author - node_id: string - tag_name: string - target_commitish: string - name: string - draft: boolean - prerelease: boolean - created_at: string - published_at: string - assets: any[] - tarball_url: string - zipball_url: string - body: string - mentions_count: number -} diff --git a/docs/.vitepress/replaceTextPlugin.ts b/docs/.vitepress/replaceTextPlugin.ts deleted file mode 100644 index 8227d8d..0000000 --- a/docs/.vitepress/replaceTextPlugin.ts +++ /dev/null @@ -1,10 +0,0 @@ -import MarkdownIt from 'markdown-it'; - -export const replaceTextPlugin = (md: MarkdownIt, searchText: string, replaceText: string) => { - md.core.ruler.before('inline', 'replace-text-plugin', (state) => { - - state.tokens.forEach((token) => { - token.content = token.content.replace(searchText, replaceText); - }); - }); -} diff --git a/docs/.vitepress/repository.ts b/docs/.vitepress/repository.ts deleted file mode 100644 index 4747fd4..0000000 --- a/docs/.vitepress/repository.ts +++ /dev/null @@ -1,29 +0,0 @@ -import axios from 'axios' -import { Release } from './github/Release' - -export let AT4JRelease: Release | null; - -export const REPO_OWNER: string = 'brenoepics' -export const REPO_NAME: string = 'at4j' -export const AT4J_VERSION = async () => { - let AT4JRelease - if (AT4JRelease == undefined) { - AT4JRelease = await getLatestVersion() - } - - return AT4JRelease != null ? AT4JRelease.tag_name : "UNKNOWN" -} - -const getLatestVersion = async (): Promise => { - const response = await axios.get( - `https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest` - ) - - if (response.status === 200) { - return response.data - } - - return null; -} - - diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 7cead69..a3d04e3 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -1,2 +1,5 @@ import { VPCarbon } from 'vitepress-carbon' -export default VPCarbon + +// uncomment to test CSS variables override +// import './override.css' +export default VPCarbon \ No newline at end of file diff --git a/docs/.vitepress/theme/override.css b/docs/.vitepress/theme/override.css new file mode 100644 index 0000000..e69de29 diff --git a/docs/env.d.ts b/docs/env.d.ts index 62c6a76..6aeff95 100644 --- a/docs/env.d.ts +++ b/docs/env.d.ts @@ -1,5 +1,5 @@ declare module 'vitepress-carbon/config' { - import { UserConfig } from 'vitepress' - const config: () => Promise - export default config -} + import { UserConfig } from 'vitepress' + const config: () => Promise + export default config +} \ No newline at end of file diff --git a/docs/package.json b/docs/package.json index 239ae6e..210dc45 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,17 +1,13 @@ { - "type": "module", + "name": "vitepress-carbon-template", + "version": "0.0.1", + "description": "VitePress Carbon Template", "scripts": { - "dev": "vitepress", + "dev": "vitepress dev", "build": "vitepress build", "preview": "vitepress preview" }, "dependencies": { - "axios": "^1.6.7", - "vitepress-carbon": "^1.0.0" - }, - "devDependencies": { - "@types/markdown-it": "^12.2.3", - "@types/node": "^20.10.1", - "terser": "^5.14.2" + "vitepress-carbon": "1.0.2" } } diff --git a/docs/src/about/team.md b/docs/src/about/team.md deleted file mode 100644 index b126502..0000000 --- a/docs/src/about/team.md +++ /dev/null @@ -1,10 +0,0 @@ ---- -page: true -title: Meet the Team ---- - - - - diff --git a/docs/src/about/team/Member.ts b/docs/src/about/team/Member.ts deleted file mode 100644 index cc72460..0000000 --- a/docs/src/about/team/Member.ts +++ /dev/null @@ -1,26 +0,0 @@ -export interface Member { - name: string - avatarPic?: string - title: string - company?: string - companyLink?: string - projects: Link[] - location: string - languages: string[] - website?: Link - socials: Socials - sponsor?: boolean | string - reposPersonal?: string[] -} - -export interface Link { - label: string - url: string -} - -export interface Socials { - github: string - twitter?: string - linkedin?: string - codepen?: string -} diff --git a/docs/src/about/team/TeamList.vue b/docs/src/about/team/TeamList.vue deleted file mode 100644 index 197ba33..0000000 --- a/docs/src/about/team/TeamList.vue +++ /dev/null @@ -1,105 +0,0 @@ - - - - - diff --git a/docs/src/about/team/TeamPage.vue b/docs/src/about/team/TeamPage.vue deleted file mode 100644 index f2471f2..0000000 --- a/docs/src/about/team/TeamPage.vue +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - diff --git a/docs/src/about/team/members.json b/docs/src/about/team/members.json deleted file mode 100644 index 3d94406..0000000 --- a/docs/src/about/team/members.json +++ /dev/null @@ -1,10 +0,0 @@ -[ - { - "avatar": "https://www.github.com/brenoepics.png", - "name": "Breno A.", - "title": "Creator", - "links": [ - { "icon": "github", "link": "https://github.com/brenoepics" } - ] - } -] diff --git a/docs/src/error-reference/errors.data.ts b/docs/src/error-reference/errors.data.mts similarity index 100% rename from docs/src/error-reference/errors.data.ts rename to docs/src/error-reference/errors.data.mts diff --git a/docs/src/error-reference/index.md b/docs/src/error-reference/index.md index 910369e..1aaf4b8 100644 --- a/docs/src/error-reference/index.md +++ b/docs/src/error-reference/index.md @@ -1,6 +1,6 @@