Following up on my previous post from 2 months ago, I wrote a script to automatically add a header comment to new files.
The header contains some basic information about the file and looks like this:
'''
Pythonista template to include some basic information in a header comment
You need to save this file to '~/Documents/Templates', so that Pythonista can find and list it in the "New File" dialog
'''
__author__ = 'Lukas Kollmer'
__copyright__ = 'Copyright (c) 2016 Lukas Kollmer<lukas@kollmer.me>'
You can get the script here from my pythonista-scripts repo.
Setup
- Download the script
- Save it to the Templates folder
Usage
- Create new files by selecting the "New Script with info header" option in the "New File" dialog
- After entering a file name, Pythonista will open the file in the editor
- Now, you just need to run the new file you just created
How it works
When you run the new file, it'll ask you for some information that will be used for the header comment. Then, the script will replace itself with just the new header comment
What info goes where
You're prompted for author_name
, description
and documentation
This is how the template will be populated:
'''
${description}
${documentation}
'''
__author__ = '${author_name}'
__copyright__ = 'Copyright (c) ${year} ${author_name}'
'''