Skip to content

Commit

Permalink
Add OpenRPC documentation to JSON RPC methods
Browse files Browse the repository at this point in the history
This does not cover providing documentation for all of the JSON RPC methods. It adds the framework for documentation and a fraction of the documentation itself to demonstrate.
  • Loading branch information
lyonsil committed Dec 10, 2024
1 parent aaa1b44 commit 78536f5
Show file tree
Hide file tree
Showing 26 changed files with 1,200 additions and 116 deletions.
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"newtonsoft",
"nodebuffer",
"nums",
"openrpc",
"papi",
"papis",
"paranext",
Expand Down
17 changes: 17 additions & 0 deletions extensions/src/hello-someone/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,23 @@ export async function activate(context: ExecutionActivationContext): Promise<voi
(name: string) => {
return `Hello ${name}!`;
},
{
method: {
summary: 'Say hello to someone',
params: [
{
name: 'name',
required: true,
summary: 'Name of the person to say hello to',
schema: { type: 'string' },
},
],
result: {
name: 'greeting',
schema: { type: 'string' },
},
},
},
);

// Create a webview or get the existing webview if ours already exists
Expand Down
36 changes: 36 additions & 0 deletions extensions/src/platform-scripture-editor/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,47 @@ export async function activate(context: ExecutionActivationContext): Promise<voi
const openPlatformScriptureEditorPromise = papi.commands.registerCommand(
'platformScriptureEditor.openScriptureEditor',
openPlatformScriptureEditor,
{
method: {
summary: 'Open the scripture editor for a project',
params: [
{
name: 'projectId',
required: false,
summary: 'The project ID to open the scripture editor for',
schema: { type: 'string' },
},
],
result: {
name: 'return value',
summary: 'The ID of the opened web view',
schema: { type: 'string' },
},
},
},
);

const openPlatformResourceViewerPromise = papi.commands.registerCommand(
'platformScriptureEditor.openResourceViewer',
openPlatformResourceViewer,
{
method: {
summary: 'Open the scripture editor in read-only mode for a project',
params: [
{
name: 'projectId',
required: false,
summary: 'The project ID to open the scripture editor for',
schema: { type: 'string' },
},
],
result: {
name: 'return value',
summary: 'The ID of the opened web view',
schema: { type: 'string' },
},
},
},
);

const scriptureEditorWebViewProviderPromise = papi.webViewProviders.register(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,18 @@ async function initialize(): Promise<void> {
);
unsubscribers.add(dataProvider.dispose);
unsubscribers.add(
await papi.commands.registerCommand('platformScripture.registerCheck', registerCheck),
await papi.commands.registerCommand('platformScripture.registerCheck', registerCheck, {
method: {
summary: 'Register a new check to run on the platform',
description:
'This will only run properly within the extension host. Do not call this from the websocket. Instead implement a check runner.',
params: [],
result: {
name: 'return value',
schema: {},
},
},
}),
);
resolve();
} catch (error) {
Expand Down
108 changes: 108 additions & 0 deletions extensions/src/platform-scripture/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,24 @@ export async function activate(context: ExecutionActivationContext) {
await papi.settings.set('platformScripture.includeMyParatext9Projects', newSettingValue);
return newSettingValue;
},
{
method: {
summary: 'Toggle whether to include My Paratext 9 projects within the platform',
params: [
{
name: 'shouldInclude',
required: false,
summary: 'Whether to include My Paratext 9 projects',
schema: { type: 'boolean' },
},
],
result: {
name: 'return value',
summary: 'The new value of the setting',
schema: { type: 'boolean' },
},
},
},
);
const includeProjectsValidatorPromise = papi.settings.registerValidator(
'platformScripture.includeMyParatext9Projects',
Expand All @@ -197,6 +215,24 @@ export async function activate(context: ExecutionActivationContext) {
const openCharactersInventoryPromise = papi.commands.registerCommand(
'platformScripture.openCharactersInventory',
openPlatformCharactersInventory,
{
method: {
summary: 'Open the characters inventory',
params: [
{
name: 'webViewId',
required: false,
summary: 'The ID of the web view tied to the project that the inventory is for',
schema: { type: 'string' },
},
],
result: {
name: 'return value',
summary: 'The ID of the opened characters inventory web view',
schema: { type: 'string' },
},
},
},
);
const characterInventoryWebViewProviderPromise = papi.webViewProviders.register(
characterInventoryWebViewType,
Expand All @@ -213,6 +249,24 @@ export async function activate(context: ExecutionActivationContext) {
const openRepeatedWordsInventoryPromise = papi.commands.registerCommand(
'platformScripture.openRepeatedWordsInventory',
openPlatformRepeatedWordsInventory,
{
method: {
summary: 'Open the repeated words inventory',
params: [
{
name: 'webViewId',
required: false,
summary: 'The ID of the web view tied to the project that the inventory is for',
schema: { type: 'string' },
},
],
result: {
name: 'return value',
summary: 'The ID of the opened repeated words inventory web view',
schema: { type: 'string' },
},
},
},
);
const repeatableWordsInventoryWebViewProviderPromise = papi.webViewProviders.register(
repeatedWordsInventoryWebViewType,
Expand All @@ -229,6 +283,24 @@ export async function activate(context: ExecutionActivationContext) {
const openMarkersInventoryPromise = papi.commands.registerCommand(
'platformScripture.openMarkersInventory',
openPlatformMarkersInventory,
{
method: {
summary: 'Open the markers inventory',
params: [
{
name: 'webViewId',
required: false,
summary: 'The ID of the web view tied to the project that the inventory is for',
schema: { type: 'string' },
},
],
result: {
name: 'return value',
summary: 'The ID of the new open markers inventory web view',
schema: { type: 'string' },
},
},
},
);
const markersInventoryWebViewProviderPromise = papi.webViewProviders.register(
markersInventoryWebViewType,
Expand All @@ -237,6 +309,24 @@ export async function activate(context: ExecutionActivationContext) {
const configureChecksPromise = papi.commands.registerCommand(
'platformScripture.openConfigureChecks',
configureChecks,
{
method: {
summary: 'Open the configure checks web view',
params: [
{
name: 'webViewId',
required: false,
summary: 'The ID of the web view tied to the project that the checks are for',
schema: { type: 'string' },
},
],
result: {
name: 'return value',
summary: 'The ID of the new configure checks web view',
schema: { type: 'string' },
},
},
},
);
const configureChecksWebViewProviderPromise = papi.webViewProviders.register(
configureChecksWebViewType,
Expand All @@ -245,6 +335,24 @@ export async function activate(context: ExecutionActivationContext) {
const showCheckResultsPromise = papi.commands.registerCommand(
'platformScripture.showCheckResults',
showCheckResults,
{
method: {
summary: 'Show the check results',
params: [
{
name: 'webViewId',
required: false,
summary: 'The ID of the web view tied to the project that the checks are for',
schema: { type: 'string' },
},
],
result: {
name: 'return value',
summary: 'The ID of the new check results web view',
schema: { type: 'string' },
},
},
},
);
const showCheckResultsWebViewProviderPromise = papi.webViewProviders.register(
checkResultsListWebViewType,
Expand Down
Loading

0 comments on commit 78536f5

Please sign in to comment.