Skip to content

Allow style customization in the documentation service #6235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Ivan-Montes
Copy link
Contributor

Related: #5900

Motivation:

This change addresses feedback from multiple users requesting the ability to customize the appearance of the documentation service. The customizable elements now include:

  • Title
  • Browser tab title
  • Header bar background color
  • Color for the GotoSelect component
  • Buttons colors in the Debug component

Modifications:

Backend

  • In DocServiceBuilder, add a Map to store relevant data and a builder method for the documentation title.
  • In DocService, modify the constructor to include a new attribute.
  • In Static Nested SpecificationLoader, adjust the constructor and the generateServiceSpecification method.
  • In ServiceSpecification, create a private Map and add Getter and Setter methods.

Frontend

  • In lib/specification.tsx, include a Record<String, String> attribute in the SpecificationData interface.
  • In lib/colors.tsx, add reusable method to validate color hex code.
  • In containers/App/index.tsx, retrieve the style settings and applied them to the app's title and header.
  • In components/GotoSelect/index.tsx, apply color using inline style.
  • In containers/MethodPage/index.tsx, apply the custom color styling.
  • In containers/MethodPage/DebugPage.tsx, apply custom button color styling via inline styles.

Result:

We can now customize the appearance of:

  • Title
  • Browser tab title
  • Header bar background color
  • Color for the GotoSelect component
  • Buttons colors in the Debug component

Main view
main_view

Debug modal
debug_modal

Copy link

codecov bot commented May 12, 2025

Codecov Report

Attention: Patch coverage is 82.85714% with 12 lines in your changes missing coverage. Please review.

Project coverage is 74.67%. Comparing base (8150425) to head (c25ee87).
Report is 105 commits behind head on main.

Files with missing lines Patch % Lines
...inecorp/armeria/server/docs/DocServiceBuilder.java 12.50% 7 Missing ⚠️
...ria/server/docs/DocServiceInjectedScriptsUtil.java 90.74% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6235      +/-   ##
============================================
+ Coverage     74.46%   74.67%   +0.21%     
- Complexity    22234    22561     +327     
============================================
  Files          1963     1981      +18     
  Lines         82437    83275     +838     
  Branches      10764    10828      +64     
============================================
+ Hits          61385    62188     +803     
- Misses        15918    15931      +13     
- Partials       5134     5156      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Ivan-Montes Ivan-Montes force-pushed the feature/allow-custom-doc-service branch from ce4d1cc to 37379c0 Compare May 15, 2025 10:48
@Ivan-Montes
Copy link
Contributor Author

I think this approach aligns better with your suggestions now. Let me know what you think!

We can now customize the appearance of:

  • Header title
  • Header bar background color
  • Color for the GotoSelect component
  • Browser tab title
  • Browser tab favicon

main_view_re

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, left only nits

* @param url the input string to escape
* @return the escaped string
*/
private static String escapeForJavaScriptUrl(String url) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question) Would it make sense to use URLEncoder.encode(url, "UTF-8") instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's definitely a more convenient method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ultimately had to use a different approach because the href attribute of the <link> HTML tag didn’t correctly interpret the value generated by the URLEncoder.encode(url, "UTF-8") method, and the icon wasn't displayed.

error404_href_link_tag

---

Related: line#5900

**Motivation:**

This change addresses feedback from multiple users requesting the ability to customize the appearance of the documentation service. The customizable elements now include:
- Title
- Browser tab title
- Header bar background color
- Color for the `GotoSelect` component
- Buttons colors in the `Debug` component

**Modifications:**

Backend
- In `DocServiceBuilder`, add a `Map` to store relevant data and a builder method for the documentation title.
- In `DocService`, modify the constructor to include a new attribute.
- In Static Nested `SpecificationLoader`, adjust the constructor and the `generateServiceSpecification` method.
- In `ServiceSpecification`, create a private `Map` and add Getter and Setter methods.

Frontend
- In `lib/specification.tsx`, include a `Record<String, String>` attribute in the `SpecificationData` interface.
- In `lib/colors.tsx`, add reusable method to validate color hex code.
- In `containers/App/index.tsx`, retrieve the style settings and applied them to the app's title and header.
- In `components/GotoSelect/index.tsx`, apply color using inline style.
- In `containers/MethodPage/index.tsx`, apply the custom color styling.
- In `containers/MethodPage/DebugPage.tsx`, apply custom button color styling via inline styles.

**Result:**

We can now customize the appearance of:
- Title
- Browser tab title
- Header bar background color
- Color for the `GotoSelect` component
- Buttons colors in the `Debug` component
…pts`

---

Related: line#5900

**Motivation:**

This change addresses feedback from multiple users requesting the ability to customize the appearance of the documentation service. The customizable elements now include:
- Header title
- Header bar background color
- Color for the `GotoSelect` component
- Browser tab title
- Browser tab favicon

**Modifications:**

Backend
- In `DocServiceBuilder`, add a `Map` to store relevant data and a builder method for the documentation title.
- In `DocService`, modify the constructor to include a new attribute.
- In Static Nested `SpecificationLoader`, adjust the constructor and the `generateServiceSpecification` method.
- In `ServiceSpecification`, create a private `Map` and add Getter and Setter methods.
- In `DocServiceInjectedScriptsUtil`, add methods to generate customization scripts.
- In `DocServiceInjectedScriptsUtilTest`, develop tests for the above logic.

Frontend
- In `lib/specification.tsx`, include a `Record<String, String>` attribute in the `SpecificationData` interface.
- In `containers/App/index.tsx`, retrieve the title and apply it to the app's titles. Add JS hook class.
- In `components/GotoSelect/index.tsx`, add JS hook class for custom behavior.

**Result:**

- Closes: line#5900

We can now customize the appearance of:
- Header title
- Header bar background color
- Color for the `GotoSelect` component
- Browser tab title
- Browser tab favicon
@Ivan-Montes Ivan-Montes force-pushed the feature/allow-custom-doc-service branch from 37379c0 to c25ee87 Compare May 23, 2025 10:22
@github-actions github-actions bot added the Stale label Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants