Skip to content

Commit 2b8757c

Browse files
authored
(EAI-311) New C++ Docs (#390)
1 parent b96f434 commit 2b8757c

File tree

5 files changed

+74
-105
lines changed

5 files changed

+74
-105
lines changed

packages/ingest-mongodb-public/src/sources/cppDriver.test.ts

-13
This file was deleted.

packages/ingest-mongodb-public/src/sources/cppDriver.ts

-41
This file was deleted.

packages/ingest-mongodb-public/src/sources/index.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import {
2121
import { prismaSourceConstructor } from "./prisma";
2222
import { wiredTigerSourceConstructor } from "./wiredTiger";
2323
import { pyMongoSourceConstructor } from "./pyMongo";
24-
import { cppSourceConstructor } from "./cppDriver";
2524
import { mongooseSourceConstructor } from "./mongoose";
2625
import { practicalAggregationsDataSource } from "./practicalAggregations";
2726

@@ -229,6 +228,12 @@ export const snootyProjectConfig: LocallySpecifiedSnootyProjectConfig[] = [
229228
tags: ["docs", "driver", "rust"],
230229
productName: "Rust Driver",
231230
},
231+
{
232+
type: "snooty",
233+
name: "cpp-driver",
234+
tags: ["docs", "driver", "cpp", "cxx", "c++"],
235+
productName: "C++ Driver",
236+
},
232237
];
233238

234239
export const devCenterProjectConfig: DevCenterProjectConfig = {
@@ -473,7 +478,6 @@ export const sourceConstructors: SourceConstructor[] = [
473478
pyMongoSourceConstructor,
474479
mongooseSourceConstructor,
475480
prismaSourceConstructor,
476-
cppSourceConstructor,
477481
mongoDbCorpDataSource,
478482
practicalAggregationsDataSource,
479483
javaReactiveStreamsSourceConstructor,

packages/mongodb-rag-ingest/src/sources/MdOnGithubDataSource.test.ts

+49-48
Original file line numberDiff line numberDiff line change
@@ -8,78 +8,79 @@ import { Page } from "mongodb-rag-core";
88

99
jest.setTimeout(60000);
1010

11-
export function samplePathToPage(pathInRepo: string) {
12-
if (pathInRepo.endsWith("_index.md")) {
13-
pathInRepo = pathInRepo.replace("_index.md", "index.md");
14-
}
15-
return pathInRepo
16-
.replace(/^docs\/content\/mongocxx-v3/, "https://example/com")
17-
.replace(/\.md$/, "/");
18-
}
19-
const sampleConf: MakeMdOnGithubDataSourceParams = {
20-
name: "sample",
21-
repoUrl: "https://github.com/mongodb/mongo-cxx-driver/",
11+
const baseChatbotRepoConfig: MakeMdOnGithubDataSourceParams = {
12+
name: "chatbot",
13+
repoUrl: "https://github.com/mongodb/chatbot",
2214
repoLoaderOptions: {
23-
branch: "master",
24-
ignoreFiles: [/^(?!^\/docs\/content\/mongocxx-v3\/).*/],
25-
},
26-
pathToPageUrl: samplePathToPage,
27-
metadata: {
28-
productName: "C++ Driver (mongocxx)",
15+
branch: "main",
2916
},
17+
pathToPageUrl: (path) => path,
18+
extractMetadata: () => ({
19+
foo: "bar",
20+
}),
21+
};
22+
23+
const mongodbCorpConfig: MakeMdOnGithubDataSourceParams = {
24+
...baseChatbotRepoConfig,
25+
name: "mongodb-corp",
3026
frontMatter: {
3127
process: true,
32-
separator: "+++",
33-
format: "toml",
28+
separator: "---",
29+
format: "yaml",
30+
},
31+
metadata: {
32+
productName: "MongoDB Corp",
3433
},
34+
filter: (path) => path.includes("mongodb-corp"),
3535
extractTitle: (_, frontmatter) => (frontmatter?.title as string) ?? null,
36-
extractMetadata: () => ({
37-
foo: "bar",
38-
}),
3936
};
37+
38+
const ingestTestDataConfig: MakeMdOnGithubDataSourceParams = {
39+
...baseChatbotRepoConfig,
40+
name: "ingest_testData",
41+
metadata: {
42+
productName: "Ingest Test Data",
43+
},
44+
filter: (path) => path.includes("ingest/testData"),
45+
};
46+
4047
describe("MdOnGithubDataSource", () => {
4148
let pages: Page[];
49+
const samplePages: Record<string, Page | undefined> = {};
50+
const getSamplePage = (path: string) => {
51+
const samplePage = samplePages[path];
52+
assert(samplePage);
53+
return samplePage;
54+
};
4255
beforeAll(async () => {
43-
const dataSource = await makeMdOnGithubDataSource(sampleConf);
56+
const dataSource = await makeMdOnGithubDataSource(mongodbCorpConfig);
4457
pages = await dataSource.fetchPages();
58+
samplePages["mongodb-corp/chatbot/overview.md"] = pages.find((page) => {
59+
return page.url.includes("mongodb-corp/chatbot/overview.md");
60+
});
4561
});
4662
it("loads and processes a real repo of markdown files", async () => {
47-
const samplePage = pages.find((page) =>
48-
page.title?.includes("Installing the mongocxx driver")
49-
);
63+
const samplePage = getSamplePage("mongodb-corp/chatbot/overview.md");
5064
assert(samplePage);
51-
expect(samplePage?.body).toContain("install");
65+
expect(samplePage?.body).toContain(
66+
"The MongoDB AI is an advanced LLM-based chatbot"
67+
);
5268
});
5369
it("processes metadata", () => {
54-
const samplePage = pages[0];
70+
const samplePage = getSamplePage("mongodb-corp/chatbot/overview.md");
5571
expect(samplePage.metadata).toHaveProperty("foo", "bar");
56-
expect(samplePage.metadata).toHaveProperty(
57-
"productName",
58-
"C++ Driver (mongocxx)"
59-
);
72+
expect(samplePage.metadata).toHaveProperty("productName", "MongoDB Corp");
6073
});
6174
it("removes frontmatter from page body", () => {
62-
const samplePage = pages[0];
63-
expect(samplePage.body).not.toContain("+++");
75+
const samplePage = getSamplePage("mongodb-corp/chatbot/overview.md");
76+
expect(samplePage.body).not.toContain("---");
6477
});
6578
it("extracts title from frontmatter", () => {
66-
const samplePage = pages[0];
79+
const samplePage = getSamplePage("mongodb-corp/chatbot/overview.md");
6780
expect(samplePage.title).toBeTruthy();
6881
});
6982
it("works with .mdx files", async () => {
70-
const sampleConf: MakeMdOnGithubDataSourceParams = {
71-
name: "sample",
72-
repoUrl: "https://github.com/mongodb/chatbot",
73-
repoLoaderOptions: {
74-
branch: "main",
75-
},
76-
pathToPageUrl: (path) => path,
77-
metadata: {
78-
productName: "C++ Driver (mongocxx)",
79-
},
80-
filter: (path) => path.includes("ingest/testData"),
81-
};
82-
const dataSource = await makeMdOnGithubDataSource(sampleConf);
83+
const dataSource = await makeMdOnGithubDataSource(ingestTestDataConfig);
8384
const pages = await dataSource.fetchPages();
8485
expect(pages.length).toBeGreaterThan(1);
8586
expect(
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
hello mdx!
1+
+++
2+
title = "Hello, MDX!"
3+
date = "2024-01-01T00:00:00.000Z"
4+
+++
5+
6+
# Hello, MDX!
7+
8+
This is an MDX file!
9+
10+
It's got standard markdown features like code fences:
11+
12+
```js title="SomeComponent.js"
13+
import { sum } from "./math";
14+
const three = sum(1, 2);
15+
```
16+
17+
<SomeComponent />
18+
19+
It renders JSX wow!

0 commit comments

Comments
 (0)