Skip to content

Commit

Permalink
[update docs] Add source file to config/state model docs (#3464)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jan 20, 2023
1 parent 00ba85d commit f5bcdb5
Show file tree
Hide file tree
Showing 137 changed files with 713 additions and 95 deletions.
89 changes: 63 additions & 26 deletions docs/generateConfigDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,48 @@ import {
getAllFiles,
} from './util'
import fs from 'fs'
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const contents = {} as { [key: string]: any }

async function generateConfigDocs(files: string[]) {
interface Derives {
name: string
docs: string
code: string
}
interface Id {
name: string
docs: string
code: string
}
interface Conf {
name: string
docs: string
id: string
}
interface Slot {
name: string
docs: string
code: string
}
interface Config {
derives?: Derives
id?: Id
slots: Slot[]
config?: Conf
filename: string
}

function generateConfigDocs(files: string[]) {
const cwd = process.cwd() + '/'
const contents = {} as { [key: string]: Config }
extractWithComment(files, obj => {
const fn = obj.filename
const fn2 = fn.replace(cwd, '')
if (!contents[fn]) {
contents[fn] = {
derives: undefined,
id: undefined,
slots: [],
config: undefined,
filename: fn2,
}
}
const current = contents[fn]
Expand All @@ -36,21 +66,23 @@ async function generateConfigDocs(files: string[]) {
current.config = { ...obj, name, docs, id }
}
})
return contents
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
;(async () => {
await generateConfigDocs(await getAllFiles())
const contents = generateConfigDocs(await getAllFiles())

Object.values(contents).forEach(({ config, slots, id, derives }) => {
if (config) {
const idstr = id
? `### ${config.name} - Identifier
Object.values(contents).forEach(
({ config, slots, id, derives, filename }) => {
if (config) {
const idstr = id
? `### ${config.name} - Identifier
#### slot: ${id.name}`
: ''
const derivesstr = derives
? `## ${config.name} - Derives from
: ''
const derivesstr = derives
? `## ${config.name} - Derives from
${derives.docs}
Expand All @@ -59,33 +91,37 @@ ${derives.docs}
${derives.code}
\`\`\`
`
: ''
const slotstr =
`${slots.length ? `### ${config.name} - Slots` : ''}\n` +
slots
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.map(({ name, docs, code }: any) => {
return `#### slot: ${name}
: ''
const slotstr =
`${slots.length ? `### ${config.name} - Slots` : ''}\n` +
slots
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.map(({ name, docs, code }: any) => {
return `#### slot: ${name}
${docs}
\`\`\`js
${code}
\`\`\`
`
})
.join('\n')
})
.join('\n')

fs.writeFileSync(
`website/docs/config/${config.name}.md`,
`---
fs.writeFileSync(
`website/docs/config/${config.name}.md`,
`---
id: ${config.id}
title: ${config.name}
toplevel: true
---
Note: this document is automatically generated from configuration objects in
our source code. See [Config guide](/docs/config_guide) for more info
## Source file
[${filename}](https://github.com/GMOD/jbrowse-components/blob/main/${filename})
## Docs
${config.docs}
Expand All @@ -99,7 +135,8 @@ ${slotstr}
${derivesstr}
`,
)
}
})
)
}
},
)
})()
52 changes: 48 additions & 4 deletions docs/generateStateModelDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,55 @@ import {
} from './util'
import fs from 'fs'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const contents = {} as { [key: string]: any }
interface Action {
name: string
docs: string
code: string
}
interface Method {
name: string
docs: string
code: string
}
interface Getter {
name: string
docs: string
code: string
}
interface Property {
name: string
docs: string
code: string
}

interface Model {
name: string
id: string
docs: string
}
interface StateModel {
model?: Model
getters: Getter[]
methods: Method[]
properties: Property[]
actions: Action[]
filename: string
}

function generateStateModelDocs(files: string[]) {
const cwd = process.cwd() + '/'
const contents = {} as { [key: string]: StateModel }
extractWithComment(files, obj => {
const fn = obj.filename
const fn2 = fn.replace(cwd, '')
if (!contents[fn]) {
contents[obj.filename] = {
model: undefined,
getters: [],
actions: [],
methods: [],
properties: [],
filename: fn2,
}
}
const current = contents[fn]
Expand All @@ -41,14 +77,15 @@ function generateStateModelDocs(files: string[]) {
current.properties.push({ ...obj, name, docs, code })
}
})
return contents
}

// eslint-disable-next-line @typescript-eslint/no-floating-promises
;(async () => {
generateStateModelDocs(await getAllFiles())
const contents = generateStateModelDocs(await getAllFiles())

Object.values(contents).forEach(
({ model, getters, properties, actions, methods }) => {
({ model, getters, properties, actions, methods, filename }) => {
if (model) {
const getterstr =
`${getters.length ? `### ${model.name} - Getters` : ''}\n` +
Expand Down Expand Up @@ -133,6 +170,13 @@ Note: this document is automatically generated from mobx-state-tree objects in
our source code. See [Core concepts and intro to pluggable
elements](/docs/developer_guide/) for more info
## Source file
[${filename}](https://github.com/GMOD/jbrowse-components/blob/main/${filename})
## Docs
Expand Down
1 change: 1 addition & 0 deletions docs/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function extractWithComment(
const comment = ts.displayPartsToString(
symbol.getDocumentationComment(checker),
)

const fulltext = node.getFullText()
const r = {
name: symbol.getName(),
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/AlignmentsTrack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[plugins/alignments/src/AlignmentsTrack/index.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/alignments/src/AlignmentsTrack/index.ts)

## Docs

has very little config; most config and state logic is on the display
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/ArcRenderer.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[plugins/arc/src/ArcRenderer/configSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/arc/src/ArcRenderer/configSchema.ts)

## Docs

### ArcRenderer - Slots
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BamAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[plugins/alignments/src/BamAdapter/configSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/alignments/src/BamAdapter/configSchema.ts)

## Docs

used to configure BAM adapter
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BaseAssembly.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[packages/core/assemblyManager/assemblyConfigSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/packages/core/assemblyManager/assemblyConfigSchema.ts)

## Docs

This corresponds to the assemblies section of the config
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BaseChordDisplay.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[plugins/circular-view/src/BaseChordDisplay/models/baseChordDisplayConfig.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/circular-view/src/BaseChordDisplay/models/baseChordDisplayConfig.ts)

## Docs

### BaseChordDisplay - Identifier
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BaseConnection.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[packages/core/pluggableElementTypes/models/baseConnectionConfig.ts](https://github.com/GMOD/jbrowse-components/blob/main/packages/core/pluggableElementTypes/models/baseConnectionConfig.ts)

## Docs

### BaseConnection - Identifier
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BaseLinearDisplay.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[plugins/linear-genome-view/src/BaseLinearDisplay/models/configSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/linear-genome-view/src/BaseLinearDisplay/models/configSchema.ts)

## Docs

`BaseLinearDisplay` is a "base" config that is extended by classes like
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BaseRpcDriver.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[packages/core/rpc/baseRpcConfig.ts](https://github.com/GMOD/jbrowse-components/blob/main/packages/core/rpc/baseRpcConfig.ts)

## Docs

### BaseRpcDriver - Slots
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BaseTrack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[packages/core/pluggableElementTypes/models/baseTrackConfig.ts](https://github.com/GMOD/jbrowse-components/blob/main/packages/core/pluggableElementTypes/models/baseTrackConfig.ts)

## Docs

### BaseTrack - Identifier
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BasicTrack.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[plugins/linear-genome-view/src/BasicTrack/configSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/linear-genome-view/src/BasicTrack/configSchema.ts)

## Docs

synonym for FeatureTrack
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BedAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[plugins/bed/src/BedAdapter/configSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/bed/src/BedAdapter/configSchema.ts)

## Docs

### BedAdapter - Slots
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BedTabixAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[plugins/bed/src/BedTabixAdapter/configSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/bed/src/BedTabixAdapter/configSchema.ts)

## Docs

### BedTabixAdapter - Slots
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BedpeAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[plugins/bed/src/BedpeAdapter/configSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/bed/src/BedpeAdapter/configSchema.ts)

## Docs

intended for SVs in a single assembly
Expand Down
4 changes: 4 additions & 0 deletions website/docs/config/BgzipFastaAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ toplevel: true
Note: this document is automatically generated from configuration objects in our
source code. See [Config guide](/docs/config_guide) for more info

## Source file

[plugins/sequence/src/BgzipFastaAdapter/configSchema.ts](https://github.com/GMOD/jbrowse-components/blob/main/plugins/sequence/src/BgzipFastaAdapter/configSchema.ts)

## Docs

### BgzipFastaAdapter - Slots
Expand Down
Loading

0 comments on commit f5bcdb5

Please sign in to comment.