Skip to content
This repository was archived by the owner on Jan 3, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": false
}
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

<img src="./assets/logo.optimized.svg" alt="Docuraptor Logo" width=150 />

Docuraptor is an offline alternative to the [doc.deno.land](https://doc.deno.land) service.
Docuraptor is an offline alternative to the
[doc.deno.land](https://doc.deno.land) service.

It generates and serves HTML documentation for JS/TS modules with the help of [Deno's](https://deno.land) documentation parser.
It generates and serves HTML documentation for JS/TS modules with the help of
[Deno's](https://deno.land) documentation parser.

## Features

Expand All @@ -16,16 +18,16 @@ It generates and serves HTML documentation for JS/TS modules with the help of [D

`$ deno install -A https://deno.land/x/docuraptor@20200930.0/docuraptor.ts`

The permissions can be restricted.
Read the `--help` documentation for more details.
The permissions can be restricted. Read the `--help` documentation for more
details.

## Usage

`$ deno run https://deno.land/x/docuraptor@20200930.0/docuraptor.ts --help`

## Examples

![Docuraptor in w3m screencast](./assets/demo.svg)
_Docuraptor with `BROWSER=w3m`_
![Docuraptor in w3m screencast](./assets/demo.svg) _Docuraptor with
`BROWSER=w3m`_

![Docuraptor documentation screenshot](./assets/screenshot.png)
32 changes: 5 additions & 27 deletions deno_api.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// deno-lint-ignore-file camelcase
import type * as ddoc from "./deno_doc_json.ts";
import type * as info from "./deno_info_json.ts";
import { createGraph, ModuleGraph } from "./deps.ts";

const decoder = new TextDecoder();

export async function getDenoData(
specifier?: string,
{ private: priv }: { private?: boolean } = {},
): Promise<{ doc: ddoc.DocNode[]; info: info.FileInfo | null }> {
): Promise<{ doc: ddoc.DocNode[]; info: ModuleGraph | null }> {
let proc_d;
let proc_i;
try {
proc_d = Deno.run({
cmd: [
Expand All @@ -32,36 +32,14 @@ export async function getDenoData(
}

const doc_j: ddoc.DocNode[] = JSON.parse(stdout);
let info_j: info.FileInfo | null = null;
let info_j: ModuleGraph | null = null;

if (specifier !== undefined) {
proc_i = Deno.run({
cmd: [
"deno",
"info",
"--json",
"--unstable",
specifier,
],
stdin: "null",
stdout: "piped",
stderr: "piped",
});

const stdout = decoder.decode(await proc_i.output());
const stderr = decoder.decode(await proc_i.stderrOutput());
const { success } = await proc_i.status();

if (!success) {
throw { stderr };
}

info_j = JSON.parse(stdout);
info_j = await createGraph(specifier);
}

return { doc: doc_j, info: info_j };
} finally {
proc_d?.close();
proc_i?.close();
}
}
22 changes: 0 additions & 22 deletions deno_info_json.ts

This file was deleted.

20 changes: 13 additions & 7 deletions deps.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
export {
assert,
unreachable,
} from "https://deno.land/std@0.69.0/testing/asserts.ts";
export { parse as argsParse } from "https://deno.land/std@0.69.0/flags/mod.ts";
} from "https://deno.land/std@0.106.0/testing/asserts.ts";
export { parse as argsParse } from "https://deno.land/std@0.106.0/flags/mod.ts";
export { join as pathJoin } from "https://deno.land/std@0.106.0/path/mod.ts";
export { pooledMap } from "https://deno.land/std@0.106.0/async/pool.ts";
export {
serve,
ServerRequest,
} from "https://deno.land/std@0.69.0/http/server.ts";
export { join as pathJoin } from "https://deno.land/std@0.69.0/path/mod.ts";
export { pooledMap } from "https://deno.land/std@0.69.0/async/pool.ts";
bold,
italic,
underline,
} from "https://deno.land/std@0.106.0/fmt/colors.ts";
export { createGraph } from "https://deno.land/x/deno_graph@0.2.1/mod.ts";
export type {
Module,
ModuleGraph,
} from "https://deno.land/x/deno_graph@0.2.1/mod.ts";
Loading