Descriptive auto-complete comments for python in Visual Studio Code

22 views Asked by At

In VSCode for C++ by typing /** then "enter" it will produce an 'intelligent' comment block depending on whether it is the file header or a function descriptor. In the following code block, these are the default (or what I believe to be default, it is possible I installed an extension years ago that does this. If that is the case, I still haven't found a way to get support for python) comment blocks it produces after /** then "enter." If it is at the top of the file, it produces the first block with the filename, author, etc. If it is above a function, it produces the @brief, but also dynamically provides @param descriptors for each input variable and a @return as well.

/**
 * @file test.cpp
 * @author your name ([email protected])
 * @brief 
 * @version 0.1
 * @date 2024-03-05
 * 
 * @copyright Copyright (c) 2024
 * 
 */


/**
 * @brief 
 * 
 * @param j 
 * @param k 
 * @return char 
 */

char test(int j, int k)
{
    char c = j+k;
    return c;
}

My question is does such a method exist for python?

I have found a way to create custom comment snippets by modifying the python.json in 'Code/User/snippets/python.json' file for user snippets using this link. This allows me to type "header" and it will autocomplete to the following:

'''
@File    :   main.py
@Time    :   03/05/2024 21:27:11
@Author  :   Author
@Version :   1.0
@Contact :   [email protected]
@License :   (C)Copyright 2024, Author
@Desc    :   None
'''

I feel like there would be a way to modify this for the functions as well. I am aware I could create a separate user snippet for functions, and I have, however, I have not figured out how to make it dynamically produce a separate @brief line for each input parameter. If anyone knows any ways to get this to work, that would be greatly appreciated. Thank you!

** Edit 1: Part of the goal for adding these headers which I forgot to mention is for a description of the function to appear when hovering the mouse over an instance of the function. This is shown below for a function in a C++ file.

enter image description here

0

There are 0 answers