better-go-syntax icon indicating copy to clipboard operation
better-go-syntax copied to clipboard

It would be good to support Doxygen or Javadoc style comments

Open yjfvictor opened this issue 3 years ago • 1 comments

https://www.doxygen.nl/index.html

https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html

As the code below,

/**
 * @file test.go
 * @author your name ([email protected])
 * @brief a test file
 * @version 0.1
 * @date 2021-05-18
 *
 * @copyright Copyright (c) 2021
 *
 */
package main

import "fmt"

/**
 * @brief a function to swap two data
 *
 * @param[in,out] a   a pointer for the first element
 * @param[in,out] b   a pointer for the second element
 * @return int
 */
func my_swap_function(a *int, b *int) int {
	var t int = *a
	*a = *b
	*b = t
	return 0
}

/**
 * @brief main function
 */
func main() {
	var a int = 3
	var b int = 4
	var ret int = my_swap_function(&a, &b)
	if ret == 0 {
		fmt.Printf("%d %d\n", a, b)
	}
}

there is no any syntax highlight on the Doxygen comments. go

But the C code works fine on Doxygen style syntax highlight. c

Even the function toolbox supports Doxygen well. c_toolbox

I hope this feature can be supported in Go as well.

yjfvictor avatar May 18 '21 03:05 yjfvictor

I understand the desire for consistency across languages, but Go has its own idiomatic comment format, and Doxygen support would only encourage non-idiomatic comments in Go. To be blunt,

/**
 * @brief a function to swap two data
 *
 * @param[in,out] a   a pointer for the first element
 * @param[in,out] b   a pointer for the second element
 * @return int
 */
func my_swap_function(a *int, b *int) int {
	var t int = *a
	*a = *b
	*b = t
	return 0
}

is the opposite of the idiomatic code that the Go community encourages (including the snake case function name, but I assume that's not your point here).

willfaught avatar Jun 11 '22 04:06 willfaught