Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: typedoc cli packages #163

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
6c6f26a
feat: start setting up typedoc cli
cabljac Mar 25, 2022
42e8e16
chore: generate and rename typedoc parsing
cabljac Mar 25, 2022
ecae868
chore: add reader for typedoc
cabljac Mar 25, 2022
9bf27fe
chore: add class for config
cabljac Mar 28, 2022
e57c6d9
chore: generate docs.refs.json
cabljac Mar 29, 2022
c9d021f
chore: generate a page for each reference
cabljac Mar 29, 2022
445e0fd
chore: generate the reference json
cabljac Mar 29, 2022
8a3dfd6
chore: update format of docs.refs.json
cabljac Mar 29, 2022
ecda8a4
chore: handle references on api layer
cabljac Mar 29, 2022
be1ad0c
chore: started UI work
cabljac Mar 29, 2022
2ccbce4
feat: add references to frontend
cabljac Mar 30, 2022
7843371
chore: fix handling of references in config
cabljac Mar 30, 2022
eb139ef
feat: generate overview page
cabljac Mar 30, 2022
d20eb93
chore: refactor createIndexFile out
cabljac Mar 30, 2022
465e9e4
chore: update generator
cabljac Mar 30, 2022
c030427
feat: categorize sidebar by kind
cabljac Mar 31, 2022
722516d
fix: resolved LPM with typedoc references
cabljac Mar 31, 2022
c8ea0ca
fix: resolved locales with references
cabljac Mar 31, 2022
fab0fb2
cli: updated overview generated page for refs
cabljac Mar 31, 2022
6f5e71e
cli: add simple error handling
cabljac Mar 31, 2022
885d92a
docs: added instructions for typedoc support to docs
cabljac Mar 31, 2022
0ce810d
chore: update function name in example file
cabljac Mar 31, 2022
6ff680b
chore: update README.md and CHANGELOG.md and docs
cabljac Apr 1, 2022
040885b
chore: prepare for publishing to pub.dev
cabljac Apr 1, 2022
353c63a
chore: add CI to generate dart_cli binaries
cabljac Apr 1, 2022
7f66d77
chore: update npm package
cabljac Apr 1, 2022
df7c409
chore: make CLI more friendly
cabljac Apr 1, 2022
cfb0bcc
chore: fix typo
cabljac Apr 1, 2022
e91b3d7
fix: only delete docs.refs.json when it exists
cabljac Apr 1, 2022
e0110a6
chore: publish new version to npm
cabljac Apr 1, 2022
3f973d7
fix: extract tab content properly in prod
cabljac Apr 10, 2022
78912c3
chore: merge in from main
cabljac Apr 10, 2022
4c9e943
CI: add main to branches in workflow
cabljac Apr 11, 2022
95270db
Update docs/typedoc.mdx
cabljac Apr 11, 2022
c7d0260
Update packages/dart_cli/lib/src/typedoc.dart
cabljac Apr 11, 2022
f0652e7
chore: sync with main
cabljac Apr 12, 2022
a746131
chore: update project config
cabljac Apr 12, 2022
a121497
feat: add sidebar to template in dart_cli
cabljac Apr 28, 2022
6044808
chore: format
cabljac Apr 28, 2022
9118f11
feat: default npx to json
cabljac Apr 28, 2022
ade4d95
chore: publish new release of npx cli
cabljac Apr 28, 2022
b6904cd
chore: sync with main
cabljac Apr 28, 2022
f3002bf
chore: merge in main
cabljac Jun 1, 2022
99ab320
fix: overview path in sidebar must be relative
cabljac Jun 1, 2022
cb4d9a0
chore: remove logs
cabljac Jun 1, 2022
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
94 changes: 94 additions & 0 deletions .github/workflows/build_dart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: build_dart

on:
pull_request:
push:
branches:
- typedoc-cli
- main

jobs:
build_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1

- name: Install dependencies
working-directory: packages/dart_cli
run: dart pub get

- name: Compiling
working-directory: packages/dart_cli
run: dart compile exe bin/docs_page.dart -o docs_page

- name: Store binary
uses: actions/upload-artifact@v3
with:
name: linux-binary
path: packages/dart_cli/docs_page

build_macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1

- name: Install dependencies
working-directory: packages/dart_cli
run: dart pub get

- name: Compiling
working-directory: packages/dart_cli
run: dart compile exe bin/docs_page.dart -o docs_page

- name: Store binary
uses: actions/upload-artifact@v3
with:
name: macos-binary
path: packages/dart_cli/docs_page

build_windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: dart-lang/setup-dart@v1

- name: Install dependencies
working-directory: packages/dart_cli
run: dart pub get

- name: Compiling
working-directory: packages/dart_cli
run: dart compile exe bin/docs_page.dart -o docs_page.exe

- name: Store binary
uses: actions/upload-artifact@v3
with:
name: windows-binary
path: packages/dart_cli/docs_page.exe

combine_outputs:
runs-on: ubuntu-latest
needs: [build_linux, build_macos, build_windows]
steps:
- name: Download linux artifact
uses: actions/download-artifact@v3
with:
name: linux-binary
path: ~/binaries/linux
- name: Download macos artifact
uses: actions/download-artifact@v3
with:
name: macos-binary
path: ~/binaries/darwin
- name: Download windows artifact
uses: actions/download-artifact@v3
with:
name: windows-binary
path: ~/binaries/win32
- name: Store binaries
uses: actions/upload-artifact@v3
with:
name: binaries
path: ~/binaries
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ dist
repositories.json
domains.json
spelling.json
_docs.page
_docs.page
packages/dart_cli/example
packages/dart_cli/docs
1 change: 0 additions & 1 deletion api/src/controllers/raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const bundleRaw = async (
const path = (req?.query.path as string) || 'index';
const headerDepth = req?.query?.headerDepth ? parseInt(req?.query?.headerDepth as string) : 3;
const { md: markdown, config: sourceConfig } = req.body;

const bundleInstance = new Bundle({
owner: 'n/a',
repository: 'n/a',
Expand Down
11 changes: 10 additions & 1 deletion api/src/utils/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ type BundleConstructorParams = {
config?: OutputConfig;
};

export type References = {
name: string;
path: string;
kind: string;
}[];

export class Bundle {
code: string;
markdown: string;
Expand All @@ -48,6 +54,7 @@ export class Bundle {
headerDepth: number;
built: boolean;
contentFetched: boolean;
referenceConfig: References | null;

constructor({
owner,
Expand Down Expand Up @@ -77,6 +84,7 @@ export class Bundle {
this.sourceChecked = false;
this.built = false;
this.contentFetched = false;
this.referenceConfig = null;
}

// check for branch/PR ref
Expand Down Expand Up @@ -108,7 +116,7 @@ export class Bundle {
}
this.baseBranch = githubContents.baseBranch;
this.repositoryFound = githubContents.repositoryFound;

this.referenceConfig = githubContents.referenceConfig;
this.formatConfigLocales(githubContents.config);
await this.matchSymLinks();
if (githubContents.md === null) {
Expand Down Expand Up @@ -156,6 +164,7 @@ export class Bundle {
repositoryFound: this.repositoryFound,
source: this.source,
ref: this.ref,
referenceConfig: this.referenceConfig,
};
}

Expand Down
24 changes: 23 additions & 1 deletion api/src/utils/github.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import A2A from 'a2a';
import { graphql } from '@octokit/graphql';
import dotenv from 'dotenv';
import { References } from './bundle';
dotenv.config();

const getGitHubToken = (() => {
Expand Down Expand Up @@ -55,6 +56,9 @@ type PageContentsQuery = {
mdxIndex?: {
text: string;
};
referenceConfig?: {
text: string;
};
};
};

Expand All @@ -69,6 +73,7 @@ export type Contents = {
md: string | null;
path: string;
repositoryFound: boolean;
referenceConfig: References | null;
};

export async function getGitHubContents(metadata: MetaData, noDir?: boolean): Promise<Contents> {
Expand All @@ -78,7 +83,7 @@ export async function getGitHubContents(metadata: MetaData, noDir?: boolean): Pr
const [error, response] = await A2A<PageContentsQuery>(
getGithubGQLClient()({
query: `
query RepositoryConfig($owner: String!, $repository: String!, $configJson: String!, $configYaml: String!, $configToml: String!, $mdx: String!, $mdxIndex: String!) {
query RepositoryConfig($owner: String!, $repository: String!, $configJson: String!, $configYaml: String!, $configToml: String!, $mdx: String!, $mdxIndex: String!, $referenceConfig: String!) {
repository(owner: $owner, name: $repository) {
baseBranch: defaultBranchRef {
name
Expand Down Expand Up @@ -109,6 +114,11 @@ export async function getGitHubContents(metadata: MetaData, noDir?: boolean): Pr
text
}
}
referenceConfig: object(expression: $referenceConfig) {
... on Blob {
text
}
}
}
}
`,
Expand All @@ -119,6 +129,7 @@ export async function getGitHubContents(metadata: MetaData, noDir?: boolean): Pr
configToml: `${metadata.ref}:docs.toml`,
mdx: `${metadata.ref}:${absolutePath}.mdx`,
mdxIndex: `${metadata.ref}:${indexPath}.mdx`,
referenceConfig: `${metadata.ref}:docs.refs.json`,
}),
);

Expand All @@ -130,6 +141,16 @@ export async function getGitHubContents(metadata: MetaData, noDir?: boolean): Pr
};
}

let referenceConfig = null;
try {
referenceConfig = response?.repository.referenceConfig?.text
? JSON.parse(response?.repository.referenceConfig?.text)
: null;
} catch (e) {
console.error('Could not parse reference config');
console.error(e);
}

return {
repositoryFound: true,
isFork: response?.repository?.isFork ?? false,
Expand All @@ -141,6 +162,7 @@ export async function getGitHubContents(metadata: MetaData, noDir?: boolean): Pr
},
md: response?.repository.mdxIndex?.text || response?.repository.mdx?.text || null,
path: response?.repository.mdxIndex?.text ? indexPath : absolutePath,
referenceConfig,
};
}

Expand Down
28 changes: 28 additions & 0 deletions docs/typedoc.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file will be expanded on, but doesn't appear in the sidebar of our docs yet

title: Typedoc Support
description: Learn how to generate docs.page references using typedoc comments
---

# Typedoc Support

If you've added typedoc-compliant comments to your code, Docs.page is able to generate reference pages from your typedoc.json.

The steps are as follows:

1. In your root directory, generate your `typedoc.json` from your code, using the flag `--json`, and specifying your output path as `docs/typedoc.json`. You will have to install typedoc first, and the command should look similar to:

```
npm run typedoc --json docs/typedoc.json src/index.ts
```

or if you're using yarn,

```
yarn typedoc --json docs/typedoc.json src/index.ts
```

2. Add a `references` field to your `docs.json` or `docs.yaml` configuration file. This value specifies the folder in which your references will be generated. If you're unsure, set it as `Reference` or `API`.
3. Add a `typedocEntryDir` field to your `docs.json` or `docs.yaml` configuration file. This should be set as the path of the directory where your typedoc entry file is.
4. Run
`docs_page typedoc`
from your root directory.
3 changes: 2 additions & 1 deletion packages/dart_cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ build/

# Created by running the command in this directory, don't commit
docs.yaml
docs
docs
docs_page
12 changes: 10 additions & 2 deletions packages/dart_cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 1.0.0
## 0.0.1

- Initial version.
- prerelease version.

## 0.0.2

- added `help` command and made `init` command more user-friendly

## 0.0.3

- fix check for `docs.refs.json` on `typedoc` command
Loading