posener / goreadme

Generate readme file from Go doc. Now available as a Github action!
MIT License
213 stars 31 forks source link

Does it need to support line feeds #122

Closed godcong closed 1 year ago

godcong commented 1 year ago

When my note has many lines, it doesn't recognize the line break markers in the document. Maybe it's //, maybe it's \n, and eventually it merges all of them into one line

posener commented 1 year ago

The issue as you describe it makes it hard to understand what is not working and why. Please provide an example that breaks the behavior and the broken output.

godcong commented 1 year ago

@posener My notes look like this:

// YearZodiacDay returns the zodiac of year.(pa: this will auto fix zodiac with LiChun check stopped at day)
// @param time.Time
// @return Zodiac
// @return error
func YearZodiacDay(t time.Time) (Zodiac, error) {
   //dosomething
}

The final markdown looks like this

func YearZodiacDay(t time.Time) (Zodiac, error)

YearZodiacDay returns the zodiac of year.(pa: this will auto fix zodiac with LiChun check stopped at day) @param time.Time @return Zodiac @return error


For line breaks in comments, it should be reflected in the final markdown in the result. looks like this:

func YearZodiacDay(t time.Time) (Zodiac, error)

YearZodiacDay returns the zodiac of year.(pa: this will auto fix zodiac with LiChun check stopped at day) @param time.Time @return Zodiac @return error


posener commented 1 year ago

This is not how markdown works... If you want a line break you must have an empty line... You can also make it look like a list, see https://github.com/posener/goreadme/blob/master/goreadme.go#L85. On this note, I do have intentions to adopt the new go doc parser which natively supports lists.