renderer
Rendererβ
Defined in: packages/core/src/renderer.ts:381
Core renderer class responsible for generating documentation files from GraphQL schema entities. Handles the conversion of schema types to markdown/MDX documentation with proper organization.
HIERARCHY LEVELS WHEN categorySort IS ENABLED:
- Level 0 (root): Query, Mutation, Subscription, Custom Groups β 01-Query, 02-Mutation, etc.
- Level 1 (under root): Specific types within each root β 01-Objects, 02-Enums, etc.
Each level has its own CategoryPositionManager that restarts numbering at 1.
Exampleβ
Constructorsβ
Constructorβ
new Renderer(options): Renderer;
Defined in: packages/core/src/renderer.ts:402
Creates a new Renderer instance.
Parametersβ
optionsβ
Renderer construction options
Returnsβ
Exampleβ
Propertiesβ
baseURLβ
readonly baseURL: string;
Defined in: packages/core/src/renderer.ts:384
groupβ
readonly group: Maybe<Partial<Record<SchemaEntity, Record<string, Maybe<string>>>>>;
Defined in: packages/core/src/renderer.ts:382
linkRoot?β
readonly linkRoot?: string;
Defined in: packages/core/src/renderer.ts:385
mdxExtensionβ
readonly mdxExtension: string;
Defined in: packages/core/src/renderer.ts:388
optionsβ
readonly options: Maybe<RendererDocOptions>;
Defined in: packages/core/src/renderer.ts:387
outputAdapterβ
readonly outputAdapter: OutputAdapter;
Defined in: packages/core/src/renderer.ts:389
outputDirβ
readonly outputDir: string;
Defined in: packages/core/src/renderer.ts:383
prettifyβ
readonly prettify: boolean;
Defined in: packages/core/src/renderer.ts:386
Methodsβ
generateCategoryMetafileType()β
generateCategoryMetafileType(
type,
name,
rootTypeName
): Promise<string>;
Defined in: packages/core/src/renderer.ts:511
Generates the directory path and metafiles for a specific schema entity type. Creates the appropriate directory structure based on configuration options.
Parametersβ
typeβ
unknown
The schema entity type
nameβ
string
The name of the schema entity
rootTypeNameβ
SchemaEntity
The root type name this entity belongs to
Returnsβ
Promise<string>
The generated directory path
Exampleβ
generateIndexMetafile()β
generateIndexMetafile(
dirPath,
category,
options?
): Promise<void>;
Defined in: packages/core/src/renderer.ts:456
Generates an index metafile for a category directory if MDX support is available.
Parametersβ
dirPathβ
string
The directory path where the index should be created
categoryβ
string
The category name
options?β
Configuration options for the index
Returnsβ
Promise<void>
Promise that resolves when the index is generated
Exampleβ
await renderer.generateIndexMetafile("docs/types", "Types", {
collapsible: true,
collapsed: false,
});
preCollectCategories()β
preCollectCategories(rootTypeNames): void;
Defined in: packages/core/src/renderer.ts:838
Pre-collects all category names that will be generated during rendering. This allows the position manager to assign consistent positions before any files are written.
HIERARCHY LEVELS:
- Root level: Query, Mutation, Subscription, Deprecated (when grouped), custom root groups
- Nested level: operations/types (API groups), custom groups under roots
CRITICAL: Categories registered must match the NAMES USED BY THE PRINTER when generating links. The printer uses plural forms from ROOT_TYPE_LOCALE: "operations", "objects", "directives", "enums", "inputs", "interfaces", "mutations", "queries", "scalars", "subscriptions", "unions"
NOT the folder names: "operations", "types"
Parametersβ
rootTypeNamesβ
string[]
Array of root type names from the schema
Returnsβ
void
preCollectGeneratedDocPaths()β
preCollectGeneratedDocPaths(rootTypes): void;
Defined in: packages/core/src/renderer.ts:804
Pre-collects root-level generated document paths for flat hierarchy.
Parametersβ
rootTypesβ
object
Map of schema entity names to their generated types
Returnsβ
void
renderHomepage()β
renderHomepage(homepageLocation): Promise<void>;
Defined in: packages/core/src/renderer.ts:888
Renders the homepage for the documentation from a template file. Replaces placeholders in the template with actual values.
Parametersβ
homepageLocationβ
Maybe<string | symbol>
Path to the homepage template file
Returnsβ
Promise<void>
Promise that resolves when the homepage is rendered
Exampleβ
renderRootTypes()β
renderRootTypes(rootTypeName, type): Promise<Maybe<Maybe<Category>[]>>;
Defined in: packages/core/src/renderer.ts:595
Renders all types within a root type category (e.g., all Query types).
Parametersβ
rootTypeNameβ
SchemaEntity
The name of the root type (e.g., "Query", "Mutation")
typeβ
unknown
The type object containing all entities to render
Returnsβ
Promise<Maybe<Maybe<Category>[]>>
Array of rendered categories or undefined
Exampleβ
renderTypeEntities()β
renderTypeEntities(
dirPath,
name,
type,
operationNamespaceParts?,
entity?
): Promise<Maybe<Category>>;
Defined in: packages/core/src/renderer.ts:665
Renders documentation for a specific type entity and saves it to a file.
Parametersβ
dirPathβ
string
The directory path where the file should be saved
nameβ
string
The name of the type entity
typeβ
unknown
The type entity to render
operationNamespaceParts?β
string[]
The namespace parts for a namespaced operation
entity?β
SchemaEntity
The schema entity kind being rendered, e.g. queries
Returnsβ
Promise<Maybe<Category>>
The category information for the rendered entity or undefined
Exampleβ
CategoryMetafileOptionsβ
Defined in: packages/core/src/renderer.ts:224
Configuration options for category metafiles in the documentation. These options control the appearance and behavior of category sections in the sidebar.
CategoryMetafileOptions
Exampleβ
const options: CategoryMetafileOptions = {
collapsible: true,
collapsed: false,
sidebarPosition: SidebarPosition.FIRST,
styleClass: CATEGORY_STYLE_CLASS.API,
};
Propertiesβ
collapsed?β
collapsed?: boolean;
Defined in: packages/core/src/renderer.ts:226
Whether the category should be initially collapsed
collapsible?β
collapsible?: boolean;
Defined in: packages/core/src/renderer.ts:225
Whether the category should be collapsible in the sidebar
sidebarPosition?β
sidebarPosition?: number;
Defined in: packages/core/src/renderer.ts:227
Custom position in the sidebar (lower numbers appear first)
styleClass?β
styleClass?: string;
Defined in: packages/core/src/renderer.ts:228
CSS class to apply to the category for styling
RendererOptionsβ
Defined in: packages/core/src/renderer.ts:347
Constructor options for Renderer, and input to getRenderer.
Propertiesβ
baseURLβ
baseURL: string;
Defined in: packages/core/src/renderer.ts:353
Base URL for the documentation
docOptionsβ
docOptions: Maybe<RendererDocOptions>;
Defined in: packages/core/src/renderer.ts:361
Additional documentation options
groupβ
group: Maybe<Partial<Record<SchemaEntity, Record<string, Maybe<string>>>>>;
Defined in: packages/core/src/renderer.ts:357
Optional grouping configuration for schema entities
linkRoot?β
linkRoot?: string;
Defined in: packages/core/src/renderer.ts:355
Root for documentation links, forwarded to render hooks
mdxExtensionβ
mdxExtension: string;
Defined in: packages/core/src/renderer.ts:363
Optional MDX file extension to use
outputAdapter?β
outputAdapter?: OutputAdapter | null;
Defined in: packages/core/src/renderer.ts:365
Destination for generated pages; defaults to the local filesystem
outputDirβ
outputDir: string;
Defined in: packages/core/src/renderer.ts:351
Directory where documentation will be generated
prettifyβ
prettify: boolean;
Defined in: packages/core/src/renderer.ts:359
Whether to format the generated markdown
printerβ
printer: typeof IPrinter;
Defined in: packages/core/src/renderer.ts:349
The printer instance used to convert GraphQL types to markdown
API_GROUPSβ
const API_GROUPS: Required<ApiGroupOverrideType>;
Defined in: packages/core/src/renderer.ts:128
Default group names for API types and non-API types. This constant provides the base folder structure for organizing GraphQL schema entities. Can be overridden via ApiGroupOverrideType in configuration.
Exampleβ
// Default structure
const defaultGroups = API_GROUPS;
// { operations: "operations", types: "types" }
// With custom override
const customGroups = { ...API_GROUPS, operations: "queries-and-mutations" };
Seeβ
getApiGroupFolder For usage with type categorization
getApiGroupFolder()β
function getApiGroupFolder(type, groups?): string;
Defined in: packages/core/src/renderer.ts:150
Determines the appropriate folder for a GraphQL schema entity based on its type.
Parametersβ
typeβ
unknown
The GraphQL schema entity to categorize
groups?β
Maybe<boolean | ApiGroupOverrideType>
Optional custom group naming configuration
Returnsβ
string
The folder name where the entity should be placed
Exampleβ
// With default groups
const folder = getApiGroupFolder(queryType); // Returns "operations"
// With custom groups
const folder = getApiGroupFolder(objectType, { operations: "queries" }); // Returns appropriate folder
getRenderer()β
function getRenderer(options): Promise<Renderer>;
Defined in: packages/core/src/renderer.ts:1144
Factory function to create and initialize a Renderer instance. Creates the output directory and returns a configured renderer.
Parametersβ
optionsβ
Renderer construction options
Returnsβ
Promise<Renderer>
A configured Renderer instance
Exampleβ
const renderer = await getRenderer({
printer: myPrinter,
outputDir: "./docs",
baseURL: "/api",
group: groupConfig,
prettify: true,
docOptions: { force: true, index: true },
mdxExtension: ".mdx",
});
logHandlerErrors()β
function logHandlerErrors(eventName, errors): void;
Defined in: packages/core/src/renderer.ts:338
Reports errors thrown by event handlers.
Handler errors are collected rather than thrown, so without this they are dropped and the formatter's post-processing silently does nothing.
Parametersβ
eventNameβ
string
Name of the emitted event
errorsβ
Error[]
Errors collected from the handlers
Returnsβ
void