Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

template.py editing is cumbersome and underdocumented #2884

Open
nerdoc opened this issue Dec 27, 2015 · 14 comments · May be fixed by #21706
Open

template.py editing is cumbersome and underdocumented #2884

nerdoc opened this issue Dec 27, 2015 · 14 comments · May be fixed by #21706

Comments

@nerdoc
Copy link

nerdoc commented Dec 27, 2015

Currently, only the %(date)s and %(username)s variables in template.py are replaced.
There should be some generic other variables like %(projectname)s and others.
AND - the documentation for that is missing.

What I would do here:
Let the user edit this file (template.py) in the settings (instead of this button "edit template for new modules") and put some explanations there, what the variables are for etc.

@nerdoc nerdoc changed the title template.py editing is cumbersome template.py editing is cumbersome and underdocumentated Dec 27, 2015
@ccordoba12 ccordoba12 added this to the v3.0 milestone Dec 28, 2015
@ccordoba12 ccordoba12 modified the milestones: v3.1, v3.0 Dec 28, 2015
@ccordoba12
Copy link
Member

It's an interesting idea. I'm marking it as doable for a future Spyder version.

@nerdoc
Copy link
Author

nerdoc commented Dec 29, 2015

I got the idea from Eclipse. This concept is really good I think. There are more generic templates, for code, and for comments too, depending on which context. PyDev comments of new modules look like

"""
Created on ${date}

@author: ${user}
"""
${cursor}

But this is completely configurable within the preferences dialog.

And furthermore, you could add optional default LICENSE headers, that are added to each file at the top.

@goanpeca
Copy link
Member

If we are going in this direction let's use jinja2. It is already a (indirect) dependency for spyder and is a well defined and documented templating language.

@goanpeca goanpeca changed the title template.py editing is cumbersome and underdocumentated template.py editing is cumbersome and underdocumented Dec 29, 2015
@nerdoc
Copy link
Author

nerdoc commented Dec 29, 2015

Ok - isn't that a bit overkill, using a whole template language with loops etc, for just having a few variables? It could be done by just replacing ${.*} with the variables?

@goanpeca
Copy link
Member

We start with few variables and after some months we end up having to maintain and document a "simple home made template language"... not a chance.

I prefer having an "overkill" (well defined proven stable and maintained) template language, that already is included when spyder is installed, than having to put a burden (however minimal) on the developer team

@goanpeca
Copy link
Member

Eclipse did it like that and that probably makes sense for Eclipse, (which is coded in Java)

@ccordoba12 I am 👎 on implementing things like ${user} for Spyder (Python based), if we can use a well known standard like {{user}}, even more if it is already a dependency.

@nerdoc
Copy link
Author

nerdoc commented Dec 29, 2015

Ok, FULL ACK. Seems really comprehensible.

@Nodd
Copy link
Contributor

Nodd commented Mar 4, 2016

Python has a string template, which is proven stable and maintained, and is not overkill. Using jinja to replace a few variables is really overkill, it's better to keep it as an indirect dependency rather than a hard one.
But the main point of the issue is to be able to edit the template directly in the preferences.

@goanpeca
Copy link
Member

goanpeca commented Mar 4, 2016

Agree with @Nodd, we can use string template ;-)

@manmartgarc
Copy link

Hi, has there any work done on this? I would love to contribute with this.

@ccordoba12
Copy link
Member

Nop, you're welcome to work on it. Please read our Contributing guide before starting:

https://github.com/spyder-ide/spyder/blob/master/CONTRIBUTING.md

@myidealab
Copy link

File Name: ${file} would be a nice addition, as well.

@ccordoba12 ccordoba12 modified the milestones: 4.1.0, future Dec 12, 2019
@goanpeca goanpeca removed this from the future milestone Feb 23, 2020
@TheReverendWilson
Copy link

Having usable variables like PyCharm's would be good, especially the configurable ones. For instance, my group anaconda's python in a standardized location, but can be changed based on an environment variable, or is updated (and renamed to reflect) when new features are added, so having the ability to read an environment variable to generate the shebang would be nice.

@kookma
Copy link

kookma commented Feb 9, 2024

bump!

  • It is good to be able to edit template.py in in the settings (instead of this button "edit template for new modules") as @nerdoc proposed.
  • allow format the date
  • all add other plcaeholder just like %(date) for filename, projectname, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants