Hi Trey,
Thanks for your response. I did some gap analysis and here are some of my
findings:
Regarding the parser,
Currently, there is only “get_properties” function as the interface for
editor-core-py which takes in “filepath” as argument and calls
EditorConfigHandler class’ get_configurations method and returns the
EditorConfig options just for the “filepath” specified as argument.
However, the behavior that will be easier for us to consume is to extract
the all the section names and corresponding configurations from the
".editorconfig" like a normal parser for any file.
We can have a EditorConfigParser class that doesn’t require filepath to
initialize and simply searches for “.editorconfig” file in the project
directory and returns the parsed version if found. An example of the parsed
result can look like :-
{
"*.in": {
"trim_trailing_whitespace": "false"
},
"*.md": {
"indent_style": "space",
"indent_size": "4"
}
}
The file
https://github.com/editorconfig/editorconfig-core-py/blob/master/editorconfig/ini.py
is complete parser in itself but doesn’t expose any function that can be
called to return a python-object after parsing the sections of
“.editorconfig” file. This is the reason I had to make slight modifications
to existing ini.py to adapt to simple parser requirements (
https://github.com/satwikkansal/coala-quickstart/blob/79/coala_quickstart/parsers/editorconfig_parser.py
). I think similar changes can be easily be chipped into official
“editorconfig-py” and exposed as a method so that we can easily use the
official library.
Regarding the Generator,
I’m sorry none of the coala member were able to have a conversation with
you regarding this idea at this year’s PyCon. The primary objective of the
generator is to develop a editorconfig-coafile interface that has methods
to read any of the two and generate the other in case of absence. I’m
trying to come up with an appropriate design for the generator. If you have
any thoughts and ideas, please let me know.
On Friday, 28 April 2017 14:17:19 UTC+5:30, Satwik Kansal wrote:
>
> Hi,
>
> This email is on behalf of the community of coala, a Python-based static
> code analysis tool.
> We’re trying to integrate a few features related to .editorconfig files
> into coala. These features require us to parse and generate “.editorconfig”
> files. We would like to collaborate with the editorconfig community to
> develop standard python packages for parsing and generating .editorconfig
> files.
>
> For parsing, we found https://github.com/editorconfig/editorconfig-core-py
> but it doesn’t perform simple parsing. Realizing the editorconfig format is
> similar to “.ini” configuration file format, a prototype implementation of
> “editorconfig” parser adapted from editorconfig-core-py that can be used
> for a more general use by projects like coala is:
>
> https://github.com/satwikkansal/coala-quickstart/blob/79/coala_quickstart/parsers/editorconfig_parser.py
> Similarly, it is possible to create “editorconfig” files programmatically
> using ConfigParser’s capability of writing sections for config files.
>
> With official packages for parsing and creating “.editorconfig”, it would
> be possible for other projects to develop something that utilizes the style
> configurations in the “.editorconfig”, or to generate “.editorconfig” files
> automatically based on some logic. Here’s how coala plans to use these
> libraries:
>
> 1. Generating “.editorconfig” file from the “.coafile” (coala’s
> configuration file): This will allow coala users to automatically generate
> “.editorconfig" file, so that they are able to use the same style
> preferences as provided by them in the coafile when working in editors that
> editorconfig supports. Related issue:
> https://github.com/coala/coala/issues/4098 .
> 2. Use the style configurations from “.editorconfig” file: This
> information can be directly used by coala as settings for the static code
> analysis routines and perform a more tailored analysis. Related issue:
> https://github.com/coala/coala-quickstart/issues/79
>
> Both the above features will help to closely integrate “.coafile” and
> “.editorconfig”. The editor plugins will be able to generate the other if
> one of them is absent. Or if both of the “coafile” and “.editorconfig”
> files are present, the consistency of style preferences could be checked
> and a warning may be raised to the users if they go out of sync. This would
> also allow coala to seamlessly support “.editorconfig” files.
>
> It’d be really nice to have official libraries for generator and parser so
> that the projects utilizing editorconfig don’t have to maintain their own
> custom parser and keep up with upstream changes now and then.
>
> coala’s community will be more than happy to collaborate in implementing
> libraries for editorconfig. We would like to hear your views and opinions
> on this. If you guys are interested in this project, we can further discuss
> it at our gitter channel: https://gitter.im/coala/coala or in this thread
> as per your convenience.
>
> Thanks and Regards,
> The coala community
>
>
--
You received this message because you are subscribed to the Google Groups
"EditorConfig" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/editorconfig.
For more options, visit https://groups.google.com/d/optout.