Skip to content

Commit

Permalink
generation skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
kainpets committed Jun 25, 2024
1 parent 2f35763 commit cfe2492
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 17 deletions.
96 changes: 96 additions & 0 deletions src/lib/generate-docstrings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

Check failure on line 1 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Format code

Missing return type on function
function generateDocstringsForBlueprint(blueprint) {

Check failure on line 2 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Parameter 'blueprint' implicitly has an 'any' type.

Check failure on line 2 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Parameter 'blueprint' implicitly has an 'any' type.

Check failure on line 2 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Build / Package

Parameter 'blueprint' implicitly has an 'any' type.
blueprint.routes.forEach(route => {

Check failure on line 3 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Format code

Unexpected console statement

Check failure on line 3 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Parameter 'route' implicitly has an 'any' type.

Check failure on line 3 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Parameter 'route' implicitly has an 'any' type.

Check failure on line 3 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Build / Package

Parameter 'route' implicitly has an 'any' type.
console.log(generateRouteDocstring(route))
route.endpoints.forEach(endpoint => {

Check failure on line 5 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Format code

Unexpected console statement

Check failure on line 5 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Parameter 'endpoint' implicitly has an 'any' type.

Check failure on line 5 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Parameter 'endpoint' implicitly has an 'any' type.

Check failure on line 5 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Build / Package

Parameter 'endpoint' implicitly has an 'any' type.
console.log(generateEndpointDocstring(endpoint))
})
route.subroutes.forEach(subroute => {

Check failure on line 8 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Format code

Unexpected console statement

Check failure on line 8 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Parameter 'subroute' implicitly has an 'any' type.

Check failure on line 8 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Parameter 'subroute' implicitly has an 'any' type.

Check failure on line 8 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Build / Package

Parameter 'subroute' implicitly has an 'any' type.
console.log(generateRouteDocstring(subroute))
})
})
}

Check failure on line 13 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Format code

Missing return type on function
function generateRouteDocstring(route) {

Check failure on line 14 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Parameter 'route' implicitly has an 'any' type.

Check failure on line 14 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Parameter 'route' implicitly has an 'any' type.

Check failure on line 14 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Build / Package

Parameter 'route' implicitly has an 'any' type.
const docstring = `
/**
* ${route.name}
*
* Path: ${route.path}
*
* Description: ${route.description ?? "No description provided."}
*
* Namespace: ${route.namespace !== '' ? route.namespace.name : "No namespace"}
*
* Endpoints:
* ${route.endpoints.map(endpoint => ` - ${endpoint.name}: ${endpoint.description}`).join('\n')}

Check failure on line 26 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Parameter 'endpoint' implicitly has an 'any' type.

Check failure on line 26 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Parameter 'endpoint' implicitly has an 'any' type.

Check failure on line 26 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Build / Package

Parameter 'endpoint' implicitly has an 'any' type.
*/`

return docstring
}

Check failure on line 31 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Format code

Missing return type on function
function generateEndpointDocstring(endpoint) {

Check failure on line 32 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Parameter 'endpoint' implicitly has an 'any' type.

Check failure on line 32 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Parameter 'endpoint' implicitly has an 'any' type.

Check failure on line 32 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Build / Package

Parameter 'endpoint' implicitly has an 'any' type.
const deprecationNotice = endpoint.isDeprecated === true ? ` (Deprecated: ${endpoint.deprecationMessage})` : ''

const docstring = `
/**
* ${endpoint.name}${deprecationNotice}
*
* Path: ${endpoint.path}
*
* Methods: ${endpoint.methods.join(', ')}
*
* Description: ${endpoint.description ?? "No description provided."}
*
* Parameters:
* ${endpoint.parameters.map(param => ` - ${param.name}: ${param.description}${param.isRequired === true ? ' (Required)' : ''}` +

Check failure on line 46 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v18)

Parameter 'param' implicitly has an 'any' type.

Check failure on line 46 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Typecheck (Node.js v20)

Parameter 'param' implicitly has an 'any' type.

Check failure on line 46 in src/lib/generate-docstrings.ts

View workflow job for this annotation

GitHub Actions / Build / Package

Parameter 'param' implicitly has an 'any' type.
`${param.isDeprecated === true ? ` (Deprecated: ${param.deprecationMessage})` : ''}`).join('\n')}
*
* Request: ${endpoint.request.semanticMethod !== '' ? `Semantic Method: ${endpoint.request.semanticMethod}` : "Not specified"}
*
* Response: ${endpoint.response.description ?? "No description provided."}
*/`

return docstring
}

const exampleRoute = {
name: "Get Devices",
path: "/devices",
description: "Retrieves a list of devices.",
namespace: null,
endpoints: [
{
name: "List Devices",
path: "/devices/list",
methods: ["GET"],
semanticMethod: "GET",
preferredMethod: "GET",
description: "Lists all devices.",
isDeprecated: false,
deprecationMessage: "",
parameters: [
{ name: "limit", isRequired: false, isDeprecated: false, deprecationMessage: "", description: "What are endpoint parameters? How are they differnet from request params?" }
],
request: {
methods: ["GET"],
semanticMethod: "GET",
preferredMethod: "GET",
parameters: [
{ name: "limit", isRequired: false, isDeprecated: false, deprecationMessage: "", description: "Limit the number of devices returned." }
]
},
response: {
description: "A list of devices."
}
}
],
subroutes: []
}

const blueprintExample = {
name: "Device API",
routes: [exampleRoute]
}

generateDocstringsForBlueprint(blueprintExample)
17 changes: 0 additions & 17 deletions src/lib/seam/connect/routes/devices.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cfe2492

Please sign in to comment.