Skip to content

Commit 8f72c64

Browse files
committed
Remove per-component .md endpoints
1 parent 9502738 commit 8f72c64

3 files changed

Lines changed: 6 additions & 40 deletions

File tree

src/main/java/io/jenkins/plugins/designlibrary/Home.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ public UISample getDynamic(String name) {
6262
* Serves LLM-friendly content as plain text markdown.
6363
*
6464
* <ul>
65-
* <li>{@code llms.txt} - index of all components with links to individual pages</li>
65+
* <li>{@code llms.txt} - index of all components</li>
6666
* <li>{@code llms-all.txt} - all component documentation in a single file</li>
67-
* <li>{@code {component}.md} - documentation for a single component</li>
6867
* </ul>
6968
*/
7069
public void doDynamic(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException {
@@ -86,22 +85,12 @@ public void doDynamic(StaplerRequest2 req, StaplerResponse2 rsp) throws IOExcept
8685
}
8786

8887
private String resolveLlmContent(String name, StaplerRequest2 req) {
89-
String baseUrl = req.getContextPath() + "/" + getUrlName() + "/";
90-
9188
if ("llms.txt".equals(name)) {
92-
return LlmContent.generateIndex(baseUrl);
89+
return LlmContent.generateIndex();
9390
}
9491
if ("llms-all.txt".equals(name)) {
9592
return LlmContent.generateAll(req.getServletContext());
9693
}
97-
if (name.endsWith(".md")) {
98-
String componentName = name.substring(0, name.length() - 3);
99-
for (UISample sample : getAll()) {
100-
if (sample.getUrlName().equals(componentName)) {
101-
return LlmContent.generateComponentMarkdown(sample, req.getServletContext());
102-
}
103-
}
104-
}
10594
return null;
10695
}
10796

src/main/java/io/jenkins/plugins/designlibrary/LlmContent.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class LlmContent {
1919

2020
private LlmContent() {}
2121

22-
static String generateIndex(String baseUrl) {
22+
static String generateIndex() {
2323
StringBuilder sb = new StringBuilder();
2424
sb.append("# Jenkins Design Library\n\n");
2525
sb.append("> A reference library of UI components and patterns ");
@@ -28,8 +28,7 @@ static String generateIndex(String baseUrl) {
2828
for (Map.Entry<Category, List<UISample>> entry : UISample.getGrouped().entrySet()) {
2929
sb.append("## ").append(entry.getKey().getDisplayName()).append('\n');
3030
for (UISample sample : entry.getValue()) {
31-
sb.append("- [").append(sample.getDisplayName()).append("](");
32-
sb.append(baseUrl).append(sample.getUrlName()).append(".md): ");
31+
sb.append("- ").append(sample.getDisplayName()).append(": ");
3332
sb.append(sample.getDescription()).append('\n');
3433
}
3534
sb.append('\n');
@@ -55,7 +54,7 @@ static String generateAll(ServletContext context) {
5554
return sb.toString();
5655
}
5756

58-
static String generateComponentMarkdown(UISample sample, ServletContext context) {
57+
private static String generateComponentMarkdown(UISample sample, ServletContext context) {
5958
StringBuilder sb = new StringBuilder();
6059
sb.append("# ").append(sample.getDisplayName()).append("\n\n");
6160
sb.append("> ").append(sample.getDescription()).append("\n\n");

src/test/java/LlmContentTest.java

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ void llmsTxtContainsIndex() throws Exception {
2828
assertThat(content).startsWith("# Jenkins Design Library");
2929
assertThat(content).contains("## Components");
3030
assertThat(content).contains("## Patterns");
31-
assertThat(content).contains("buttons.md");
32-
assertThat(content).contains("cards.md");
31+
assertThat(content).contains("Buttons");
3332
}
3433
}
3534

@@ -46,27 +45,6 @@ void llmsAllTxtContainsAllComponents() throws Exception {
4645
}
4746
}
4847

49-
@Test
50-
void componentMarkdownContainsDescription() throws Exception {
51-
try (var webClient = jenkins.createWebClient()) {
52-
Page page = webClient.getPage(jenkins.getURL() + "design-library/buttons.md");
53-
String content = page.getWebResponse().getContentAsString();
54-
55-
assertThat(content).startsWith("# Buttons");
56-
assertThat(content).contains("**Category:** Components");
57-
assertThat(content).contains("Triggers specific actions");
58-
}
59-
}
60-
61-
@Test
62-
void unknownMdReturns404() throws Exception {
63-
try (var webClient = jenkins.createWebClient()) {
64-
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
65-
Page page = webClient.getPage(jenkins.getURL() + "design-library/nonexistent.md");
66-
assertThat(page.getWebResponse().getStatusCode()).isEqualTo(404);
67-
}
68-
}
69-
7048
@Test
7149
void existingComponentPagesStillWork() throws Exception {
7250
try (var webClient = jenkins.createWebClient().withJavaScriptEnabled(false)) {

0 commit comments

Comments
 (0)