Skip to content

Commit

Permalink
viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
bunsenstraat authored and joeizang committed Mar 9, 2023
1 parent 54f8a01 commit 0b79b64
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apps/remixdocgen/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const App = () => {
client.eventEmitter.on('docsGenerated', (docs: string[]) => {
console.log('docsGenerated', docs)
})


};

Expand All @@ -50,6 +51,7 @@ const App = () => {
<h1>Remix Docgen</h1>
{fileName && <h2>File: {fileName}</h2>}
{hasBuild && <button onClick={() => client.generateDocs()}>Generate doc</button>}
{hasBuild && <button onClick={() => client.opendDocs()}>Open docs</button>}
</div>
)
};
Expand Down
16 changes: 14 additions & 2 deletions apps/remixdocgen/src/app/docgen-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ export class DocGenClient extends PluginClient {
this.eventEmitter = new EventEmitter()
createClient(this)
// this.docgen = new DocGen()
this.methods = ['generateDocs', 'publishDocs']
this.methods = ['generateDocs', 'publishDocs', 'viewDocs']
this.onload().then(async () => {
console.log('docgen client loaded')
await this.setListeners()
})
}

async setListeners() {
this.currentTheme = await this.call('theme', 'currentTheme');
this.currentTheme = await this.call('theme', 'currentTheme')

this.on("theme", "themeChanged", (theme: any) => {
this.currentTheme = theme
this.eventEmitter.emit('themeChanged', this.currentTheme)
Expand Down Expand Up @@ -64,6 +65,17 @@ export class DocGenClient extends PluginClient {
this.eventEmitter.emit('docsGenerated', docs)
}

async opendDocs() {
console.log('docgen client openDocs')
await this.call('manager', 'activatePlugin', 'docgenviewer')
await this.call('tabs' as any, 'focus', 'docgenviewer')
await this.call('docgenviewer' as any, 'viewDocs')
}

async viewDocs(docs: string[]) {
console.log('docgen client viewDocs')
}

async generateDocs() {
console.log('docgen client generateDocs')
this.docgen([this.build])
Expand Down

0 comments on commit 0b79b64

Please sign in to comment.