generator icon indicating copy to clipboard operation
generator copied to clipboard

[📑 Docs]: Provide content for `Template` document

Open derberg opened this issue 1 year ago • 1 comments

What Dev Docs changes are you proposing?

https://github.com/asyncapi/generator/blob/master/docs/template.md

Not sure what you think but probably it should be in structure next to AsyncAPI Specification File document. Why? Introduction explains generator and introduces terms like AsyncAPI file and Template, so this is why naturally I think they should be explained one after another.

So we close the scope of this document to explain what template is, and not how to create a template. We only need to explain the minimum structure of the template -> https://github.com/asyncapi/template-for-generator-templates#minimum-for-your-template

  • template is a nodejs project, that is not related to repository of Generator. It can be released separately, managed separately, published separately. Generator uses arborist library (the same that npm uses internally) to fetch source code of the template to be able to use it for generation. It means template can be stored anywhere, in npm, on local while development or just on github. You can do anything that is already possible with npm install

  • template specifies what should be generated. In other words it defines the output of the generation process

  • template, as the name suggests, is a set of file that specify what gets generated depending on the content of the AsyncAPI file. So in template you say "generate server code this way, and put server url here" and during generation AsyncAPI file content, with server URL will be injected in the template and visible in the result. Maybe diagram?

  • intro to render engines, just mention them, and explain they are responsible for how templates shoudl be written. Say that new templates should follow React engine

  • maybe show simple template? as part of what you write about template minimum setup?

    //package.json
    {
    "generator": {
        "renderer": "react"
    },
    "dependencies": {
        "@asyncapi/generator-react-sdk": "^0.2.25"
    }
    }
    
    //template/index.js
    
    import { File, Text } from "@asyncapi/generator-react-sdk";
    
    export default function({ asyncapi, params, originalAsyncAPI }) {
    return (
        <File name="asyncapi.md">
        <Text>This is a markdown file for my application.</Text>
        <Text>App name is: **{ asyncapi.info().title() }**</Text>
        </File>
    );
    }
    

cc @pratik2315 @Florence-Njeri

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

derberg avatar Jul 21 '22 14:07 derberg

Hey there! I'll be working on this issue for Template documentation.

pratik2315 avatar Sep 27 '22 12:09 pratik2315

:tada: This issue has been resolved in version 1.9.15 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

asyncapi-bot avatar Jan 17 '23 16:01 asyncapi-bot