Skip to content

Commit

Permalink
Merge pull request #16 from schoero/development
Browse files Browse the repository at this point in the history
chore(release): v0.2.6
  • Loading branch information
schoero authored Nov 12, 2023
2 parents d4ebf83 + c27f50b commit 9af2fbd
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 14 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## v0.2.6

[compare changes](https://github.com/schoero/unwritten/compare/v0.2.5...v0.2.6)

### Features

- Make rendering of table of contents optional ([ca33ef2](https://github.com/schoero/unwritten/commit/ca33ef2))

### Fixes

- Browser import ([c3dd914](https://github.com/schoero/unwritten/commit/c3dd914))

### ❤️ Contributors

- Roger Schönbächler

## v0.2.5

[compare changes](https://github.com/schoero/unwritten/compare/v0.2.3...v0.2.5)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.2.5",
"version": "0.2.6",
"type": "module",
"name": "unwritten",
"description": "unwritten is a cli tool that auto generates documentation from your JavaScript or TypeScript project by utilizing TSDoc or JSDoc comments.",
Expand All @@ -13,8 +13,8 @@
"bugs": {
"url": "https://github.com/schoero/unwritten/issues"
},
"main": "./lib/api/node.js",
"browser": "./lib/api/browser.js",
"main": "./lib/api/node.entry.js",
"browser": "./lib/api/browser.entry.js",
"bin": "./lib/bin/index.js",
"scripts": {
"build": "vite build",
Expand Down
8 changes: 8 additions & 0 deletions schemas/renderer/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@
"description": "Defines whether the renderer should render links to the source code.",
"type": "boolean"
},
"renderTableOfContents": {
"description": "Defines whether the renderer should render the table of contents.",
"type": "boolean"
},
"sidebar": {
"description": "Renders the table of contents in an aside element and the documentation in a main element.",
"type": "boolean"
Expand Down Expand Up @@ -669,6 +673,10 @@
"description": "Defines whether the renderer should render links to the source code.",
"type": "boolean"
},
"renderTableOfContents": {
"description": "Defines whether the renderer should render the table of contents.",
"type": "boolean"
},
"sectionSeparator": {
"anyOf": [
{
Expand Down
3 changes: 0 additions & 3 deletions src/api/browser.entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@ export async function unwritten(code: string, options?: BrowserAPIOptions): Prom
ts
});


// Compile
const { checker, program } = compile(defaultContext, code, options?.tsconfig);


// Parse
const config = await createConfig(defaultContext, options?.config);
const interpreterContext = createInterpreterContext(defaultContext, checker, config);
const entryFileSymbol = getEntryFileSymbolsFromProgram(interpreterContext, program);
const parsedSymbols = interpret(interpreterContext, entryFileSymbol);


// Render
const renderer = await getRenderer(options?.renderer);
const renderContext = createRenderContext(defaultContext, renderer, config);
Expand Down
1 change: 1 addition & 0 deletions src/renderer/markup/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const defaultRenderConfig: Complete<MarkupRenderConfig> = {
renderParentNames: "documentation",
renderPrivateMembers: false,
renderSourceCodeLinks: true,
renderTableOfContents: true,
stringLiteralEncapsulation: ["\"", "\""],
tagEncapsulation: ["`", "`"],
translations: {
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/markup/html/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { getDestinationFilePath } from "unwritten:renderer/markup/utils/file";
import { createSectionNode, createTitleNode } from "unwritten:renderer/markup/utils/nodes";
import { capitalize } from "unwritten:renderer/markup/utils/translations";
import { getRenderConfig } from "unwritten:renderer/utils/config.js";
import { renderNewLine } from "unwritten:renderer/utils/new-line";
import { renderAnchorNode } from "unwritten:renderer:html/ast/anchor";
import { renderBoldNode } from "unwritten:renderer:html/ast/bold";
Expand Down Expand Up @@ -115,6 +116,8 @@ const htmlRenderer: HTMLRenderer = {

htmlRenderer.initializeContext(ctx);

const renderConfig = getRenderConfig(ctx);

return sourceFileEntities.reduce<(SourceFileEntity & { documentation: ASTNode[]; tableOfContents: ASTNode; title: string; titleAnchor: AnchorTarget; })[]>((convertedSourceFileEntities, sourceFileEntity) => {

const destination = getDestinationFilePath(ctx, sourceFileEntities, sourceFileEntity);
Expand Down Expand Up @@ -143,11 +146,15 @@ const htmlRenderer: HTMLRenderer = {

setCurrentSourceFile(ctx, convertedSourceFileEntity);

const tableOfContents = renderConfig.renderTableOfContents &&
createSectionNode("table-of-contents", convertedSourceFileEntity.tableOfContents);
const documentation = createSectionNode("documentation", ...convertedSourceFileEntity.documentation);

const ast = createTitleNode(
convertedSourceFileEntity.title,
convertedSourceFileEntity.titleAnchor,
createSectionNode("table-of-contents", convertedSourceFileEntity.tableOfContents),
createSectionNode("documentation", ...convertedSourceFileEntity.documentation)
tableOfContents,
documentation
);

const renderedNewLine = renderNewLine(ctx);
Expand Down
11 changes: 9 additions & 2 deletions src/renderer/markup/markdown/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import { getDestinationFilePath } from "unwritten:renderer/markup/utils/file";
import { createSectionNode, createTitleNode } from "unwritten:renderer/markup/utils/nodes";
import { capitalize } from "unwritten:renderer/markup/utils/translations";
import { getRenderConfig } from "unwritten:renderer/utils/config.js";
import { renderWithIndentation } from "unwritten:renderer/utils/indentation";
import { renderNewLine } from "unwritten:renderer/utils/new-line";
import { renderAnchorNode } from "unwritten:renderer:markdown/ast/anchor";
Expand Down Expand Up @@ -118,6 +119,8 @@ const markdownRenderer: MarkdownRenderer = {

const { getFileName } = ctx.dependencies.path;

const renderConfig = getRenderConfig(ctx);

const renderedNewLine = renderNewLine(ctx);
const renderedEmptyLine = renderEmptyLine(ctx);

Expand Down Expand Up @@ -151,11 +154,15 @@ const markdownRenderer: MarkdownRenderer = {

setCurrentSourceFile(ctx, convertedSourceFileEntity);

const tableOfContents = renderConfig.renderTableOfContents &&
createSectionNode("table-of-contents", convertedSourceFileEntity.tableOfContents);
const documentation = createSectionNode("documentation", ...convertedSourceFileEntity.documentation);

const ast = createTitleNode(
convertedSourceFileEntity.title,
convertedSourceFileEntity.titleAnchor,
createSectionNode("table-of-contents", convertedSourceFileEntity.tableOfContents),
createSectionNode("documentation", ...convertedSourceFileEntity.documentation)
tableOfContents,
documentation
);

const renderedContent = renderNode(ctx, ast);
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/markup/types-definitions/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ export interface MarkupRenderConfig {
/** Defines whether the renderer should render links to the source code. */
renderSourceCodeLinks?: boolean;

/** Defines whether the renderer should render the table of contents. */
renderTableOfContents?: boolean;

/** Defines how string literal type annotations should be encapsulated in the rendered output. */
stringLiteralEncapsulation?: Encapsulation | false;

Expand Down
10 changes: 8 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import shebang from "rollup-plugin-preserve-shebang";
import dts from "vite-plugin-dts";
import noBundlePlugin from "vite-plugin-no-bundle";

import { config, defineConfig } from "@schoero/vite-config";
Expand All @@ -9,7 +10,7 @@ export default defineConfig({
build: {
emptyOutDir: true,
lib: {
entry: "/src/bin/index.ts",
entry: ["/src/bin/index.ts", "/src/api/browser.entry.ts"],
formats: ["es"]
},
minify: false,
Expand All @@ -25,6 +26,11 @@ export default defineConfig({
plugins: [
...config.plugins ?? [],
noBundlePlugin(),
shebang()
shebang(),
dts({
entryRoot: "./src",
exclude: ["src/**/*.test.ts", "test/**"],
pathsToAliases: true
})
]
});

0 comments on commit 9af2fbd

Please sign in to comment.