230612-VSCode中自定义AutoDocstring模板样式

  • AutoDocstring插件官网

  • google docstring template

  • 修改.mustache模板文件如下,记住该模板文件的位置,后续设置需要设置该模板的路径

  • 注意:删除第3行,第6行的空行,可以减少插入模板中的间距!

{
   
   {! Google Docstring Template }}
{
   
   {summaryPlaceholder}} 

{
   
   {extendedSummaryPlaceholder}}
{
   
   {#parametersExist}} 

Args:
{
   
   {#args}}
    - {
   
   {var}} (``{
   
   {typePlaceholder}}``): {
   
   {descriptionPlaceholder}}
{
   
   {/args}}
{
   
   {#kwargs}}
    {
   
   {var}} ({
   
   {typePlaceholder}}, optional): {
   
   {descriptionPlaceholder}}. Defaults to {
   
   {&default}}.
{
   
   {/kwargs}}
{
   
   {/parametersExist}}
{
   
   {#exceptionsExist}}

Raises:
{
   
   {#exceptions}}
    {
   
   {type}}: {
   
   {descriptionPlaceholder}}
{
   
   {/exceptions}}
{
   
   {/exceptionsExist}}
{
   
   {#returnsExist}}

Returns:
{
   
   {#returns}}
    - {
   
   {typePlaceholder}} (``{
   
   {typePlaceholder}}``): {
   
   {descriptionPlaceholder}}
{
   
   {/returns}}
{
   
   {/returnsExist}}
{
   
   {#yieldsExist}}

Yields:
{
   
   {#yields}}
    {
   
   {typePlaceholder}}: {
   
   {descriptionPlaceholder}}
{
   
   {/yields}}
{
   
   {/yieldsExist}}
  • 修改路径
    • 通过Ctrl+, 打开设置面板
    • 在搜索栏中搜索:customTemplatePath
    • Auto Docstring: Custom Template Path 输入 .mustache文件的绝对路径或相对路径
    • 重启VSCode生效

猜你喜欢

转载自blog.csdn.net/qq_33039859/article/details/131167498