Giter Club home page Giter Club logo

astextract's Issues

AST extracting the documentation for functions

Hey, I came across Go-App and as a result this project. Really cool - been wanting something to learn about AST for ages. This is perfect.

My goal is to try and build some components using Go-App for generating web assembly apps and then use the functions and the comments to generate the documentation as part of the web assembly site - i.e the documentation auto generates with the webassembly app which would be pretty neat.

I was playing with your application and my first question (I'm very new to AST stuff) is:

If I enter

package main
// Nav
/*
 this function adds two strings together and returns the result
*/
func Nav(str1 string, str2 string) string {
  // add the two passed strings together
   res :=str1 + str2
  return res
}

into your application I get the comments block:

  Comments: []*ast.CommentGroup {
    &ast.CommentGroup {
      List: []*ast.Comment {
        &ast.Comment {
          Slash: 14,
          Text: "// Nav",
        },
        &ast.Comment {
          Slash: 21,
          Text: "/*\n this function adds two strings together and returns the result\n*/",
        },
      },
    },
  },

which is fine. However when I remove the comment within the function, i.e // add the two passed strings together I get an empty Comments group, i.e Comments: []*ast.CommentGroup {}, - I was wondering if this is a bug or something to do with how AST is generated? I.e oes the Comments: []*ast.CommentGroup {}, need a comment in the function to read the comments above the function.

My goal is to somehow (haven't got there yet) run the AST generator over a package, pull out all the comments and then the function and add those to a markdown file which will then be rendered by my webassembly application. I think using AST is a good way to do this (as further down the line I may want more granular control over how the markdown is generated.

Also - in this case, does the AST generated "know" that the comments before the function are "part" of, i.e related to the function specifcally? - Reason I ask is that if I make a second function with leading comments, all commentGroups seem to be at the bottom of the AST generated. Is there a way for it to know those comments are related to that function?
Thanks

installable app support

Hey, I'm the creator of go-app.

I was thinking that it would be cool to have this available as an installable app. I updated the package version to v7.0.3 and it makes it possible with GitHub Pages hosted apps.

You would just have to update go-app and push it to your repo.

Also, since your app is white, you may want to tweak the handler by specifying a white theme color:

app.Handler{
    // ...
    ThemeColor: "#ffffff",
}

Best,
Maxence

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.