2017-08-29 4 views
2

Je suis en train de créer un générateur de doc-tapuscrit, mais de le faire, je dois analyser un fichier dactylographiée en quelque chose de plus facile à lireGénérer schéma JSON du tapuscrit

EX:

"Command": { 
    "description": "A command object for the command handler", 
    "constructor": [ 
     { 
     "name": "name", 
     "type": "string", 
     "optional": false, 
     "default": null, 
     "description": "Name of the command" 
     }, 
     { 
     "name": "callback", 
     "type": "(event: CommandContext) => void", 
     "optional": false, 
     "default": null, 
     "description": "Callback for the command" 
     } 
    ], 
    "properties": [ 
     { 
     "name": "name", 
     "description": "Name of the command", 
     "type": "string" 
     }, 
     { 
     "name": "fullname", 
     "description": "Fullname of the command", 
     "type": "string" 
     } 
    ], 
    "methods": [ 
     { 
     "name": "canRun", 
     "description": "Checks all permission checks and verifies if a command can be run", 
     "parameters": [ 
      { 
      "name": "context", 
      "type": "CommandContext", 
      "optional": false, 
      "default": null, 
      "description": "The context for the command", 
      "returns": "PermissionCheckResult" 
      } 
     ] 
     } 
    ], 
    "events": null 
    } 

serait viens quelque chose comme ça

export declare class Command { 
    /** 
    * Name of the command 
    */ 
    name: string; 
    /** 
    * Fullname of the command 
    */ 
    fullname: string; 
    /** 
    * Create a command 
    * @param name - Name of the command 
    * @param callback - Callback for the command 
    */ 
    constructor(name: string, callback: (event: CommandContext) => void); 
    /** 
    * Checks all permission checks and verifies if a command can be run 
    * @param context - The context for the command 
    */ 
    canRun(context: CommandContext): boolean; 
} 

comment pourrais-je accomplir ceci, de préférence dans le navigateur, mais si cela est impossible, je pourrais aussi le faire en utilisant Node.js

+1

Il n'y a pas de solution mature. Quelques liens: https://github.com/YousefED/typescript-json-schema, https://github.com/Microsoft/TypeScript/issues/14419, https://github.com/Microsoft/TypeScript/issues/3628 # emissionecomment-298236279 – Paleo

Répondre

0

TypeDoc a une fonction similaire, vous pouvez utiliser la balise --json pour obtenir des données sur le module au format JSON

ce n'est pas exactement ce que je cherchais, mais peut être utilisé pour accomplir la même chose