doi / fileheadercomment

visual studio code editor extension
MIT License
21 stars 17 forks source link

Does not support py file comment style #14

Open ronak1009 opened 4 years ago

ronak1009 commented 4 years ago

I have python files. I need to add headers to it. Following is my settings for the extensions:

   "fileHeaderComment.parameter":{
        "*":{
            // "commentbegin": "/*",
            // "commentprefix": " *",
            // "commentend": " */",
            "company": "My Company.",
            "license_text" : [  "Contains trade secrets of My Company",
                "Copyright notice does not imply publication.",
                "Decompilation or disassembly of this software is strictly prohibited."]
        }
    },
    "fileHeaderComment.template":{
        "*":[
            "${commentbegin}",
            "${commentprefix} Copyright: ${company}, ${year}. All rights reserved.",
            "${commentprefix} ${license_text}",
            "${commentend}"
        ]
    }

On running the command the format of comment added is as follows:

'''
 Copyright: My Company, 2020. All rights reserved.
 Contains trade secrets of My Company.
Copyright notice does not imply publication.
Decompilation or disassembly of this software is strictly prohibited.
'''

The comments are written as strings.

ronak1009 commented 4 years ago

@doi I have the fix ready with me. Please grant me the permission to push a separate branch for creating the merge request.

doi commented 4 years ago

can you create a pull request?

ronak1009 commented 4 years ago

Submitted the pull request.

doi commented 4 years ago

for an interim solution, add code below to your setting

"fileHeaderComment.parameter":{
  "python":{
      "commentprefix": ""
  }
}
ronak1009 commented 4 years ago

Native python does not support multiline comment blocks. Also, using triple quotes ''' some comment ''' is considered as docstring. The PEP 8 document also indicates use of # comment style. Although using docstring as multi-line comment is a small hack.

Using docstring style of multiline is also impacting the compiled files as they are larger compared to using the '#' for comments.