DEV Community

Discussion on: How to write Godoc?

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

Thanks for official guide, but of course, I did come from other languages first (like Python, JavaScript, Java).

I am also looking for Doctest (originally in Python, and may be adaptable in some other languages.) - reddit.com/r/golang/comments/bafug...

For references,

Python "Google style" docstring.

def checksum(data: Union[str, bytes]) -> str:
    """[summary]

    Args:
        data (Union[str, bytes]): [description]

    Returns:
        str: [description]
    """
    if isinstance(data, str):
        data = data.encode("utf-8")
    return sha1(data).hexdigest()
Enter fullscreen mode Exit fullscreen mode
def ankiconnect(action: str, **params):
    """[summary]

    Args:
        action (str): [description]

    Raises:
        Exception: [description]
        Exception: [description]
        Exception: [description]
        Exception: [description]

    Returns:
        [type]: [description]
    """
Enter fullscreen mode Exit fullscreen mode

JavaScript JSDoc / TypeScript TSDoc (which is almost similar to JavaDoc).

TSDoc

Again, I am looking to write Documentations that don't lose any information I wanted, not really that "Just following recommendations".

Let me complain this again...