Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comment not working for docgen #10

Closed
keith6014 opened this issue Dec 18, 2018 · 3 comments
Closed

comment not working for docgen #10

keith6014 opened this issue Dec 18, 2018 · 3 comments

Comments

@keith6014
Copy link

I have some code like this

package main                                                                                                                                                                                   
                                                                                                                                                                                               
import (                                                                                                                                                                                       
        "fmt"                                                                                                                                                                                  
        "net/http"                                                                                                                                                                             
                                                                                                                                                                                               
        "github.com/go-chi/chi"                                                                                                                                                                
        "github.com/go-chi/docgen"                                                                                                                                                             
)                                                                                                                                                                                              
                                                                                                                                                                                               
// Ping is a simple function with some comments                                                                                                                                                
func ping(w http.ResponseWriter, r *http.Request) {                                                                                                                                            
        w.Write([]byte("ping"))                                                                                                                                                                
}                                                                                                                                                                                              
func main() {                                                                                                                                                                                  
        r := chi.NewRouter()                                                                                                                                                                   
        r.Get("/ping", ping)                                                                                                                                                                   
        fmt.Printf("%v\n", docgen.JSONRoutesDoc(r))                                                                                                                                            
}           

the output is this

{
  "router": {
    "middlewares": [],
    "routes": {
      "/ping": {
        "handlers": {
          "GET": {
            "middlewares": [],
            "method": "GET",
            "pkg": "",
            "func": "main.ping",
            "comment": "",
            "file": "/mnt/cmd/go-chi/main.go",
            "line": 12
          }
        }
      }
    }
  }
}

I would of expected comment to be filled with "Ping is a simple function with some comments"

@fr3fou
Copy link

fr3fou commented Jan 21, 2020

any news?

@alinz
Copy link

alinz commented Mar 27, 2020

@keith6014 @fr3fou, in the example, you have to make the ping function exportable by rename it to Ping then you should see the comment in json.

@alinz
Copy link

alinz commented Apr 8, 2020

@pkieltyka you can close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants