对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。

手动创建注册表索引文件

警告

实验功能

此功能是实验性的。MongoDB 不支持代码片段。此功能可随时更改或删除,恕不另行通知。

预计不会出现错误,但是,如果遇到错误,请在此项目的 GitHub 存储库中提出问题。

本页讨论如何手动创建注册表索引文件。 要使用脚本生成注册表索引文件,请参阅创建注册表索引文件。

创建注册表索引文件:

  1. 复制以下 TypeScript 模板并将其保存为make-index.ts :

    import bson from 'bson';import zlib from 'zlib'; interface ErrorMatcher { // Add additional information to shell errors matching one of the regular. // expressions. The message can point to a snippet helping solve that error. matches: RegExp[]; message: string;} interface SnippetDescription { // The *npm* package name. Users do not interact with this. name: string; // The snippet name. This is what users interact with. snippetName: string; // An optional install specifier that can be used to point npm towards // packages that are not uploaded to the registry. For example, // this could be an URL to a git repository or a tarball. installSpec?: string; // A version field. Users do not interact with this, as currently, `snippet` // always installs the latest versions of snippets. version: string; description: string; readme: string; // License should be a SPDX license identifier. license: string; errorMatchers?: ErrorMatcher[];} interface SnippetIndexFile { // This must be 1 currently. indexFileVersion: 1; index: SnippetDescription[]; metadata: { homepage: string };} const indexFileContents: SnippetIndexFile = { indexFileVersion: 1, index: [ /* ... */ ], metadata: { homepage: 'https://example.com' }}; // Serialize, compress and store the index file:fs.writeFileSync('index.bson.br', zlib.brotliCompressSync( bson.serialize(indexFileContents)));
  2. 根据需要编辑代码段包的make-index.ts 。 使用注释作为填写所需信息的指南。

  3. 运行ts-node make-index.ts以创建index.bson.br file 。

  4. 将index.bson.br上传到您的 GitHub 存储库。

  5. 更新snippetIndexSourceURLs以包含引用index.bson.br的 URL。

给本页内容打分