plugins.rst 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ===============
  2. Writing Plugins
  3. ===============
  4. The EditorConfig Python Core can be easily used by text editor plugins written in Python or plugins that can call an external Python interpreter. The EditorConfig Python Core supports Python versions 2.2 to 2.7. Check out the `Vim`_ and `Gedit`_ plugins for example usages of the EditorConfig Python Core.
  5. .. _`Vim`: https://github.com/editorconfig/editorconfig-vim
  6. .. _`Gedit`: https://github.com/editorconfig/editorconfig-gedit
  7. Use as a library
  8. ----------------
  9. For instructions on using the EditorConfig Python Core as a Python library see :doc:`usage`.
  10. Using with an external Python interpreter
  11. -----------------------------------------
  12. The EditorConfig Python Core can be used with an external Python interpreter by executing the ``main.py`` file. The ``main.py`` file can be executed like so::
  13. python editorconfig-core-py/main.py /home/zoidberg/humans/anatomy.md
  14. For more information on command line usage of the EditorConfig Python Core see :doc:`command_line_usage`.
  15. Bundling EditorConfig Python Core with Plugin
  16. ---------------------------------------------
  17. A text editor or IDE plugin will either need to bundle the EditorConfig Python
  18. Core with the plugin installation package or the will need to assist the user
  19. in installing the EditorConfig Python Core. Below are instructions for
  20. bundling the EditorConfig Python Core with plugins.
  21. Bundling as a Submodule in Git
  22. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. Git submodules allow one repository to be included inside another. A submodule
  24. stores a remote repositry and commit to use for fetching the embedded
  25. repository. Submodules take up very little space in the repository since they
  26. do not actually include the code of the embedded repository directly.
  27. To add EditorConfig Python Core as a submodule in the ``editorconfig-core-py``
  28. directory of your repository::
  29. git submodule add git://github.com/editorconfig/editorconfig-core-py.git editorconfig-core-py
  30. Then every time the code is checked out the submodule directory should be
  31. initialized and updated::
  32. git submodule update --init
  33. Bundling as a Subtree in Git
  34. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. Git subtrees are convenient because, unlike submodules, they do not require any
  36. extra work to be performed when cloning the git repository. Git subtrees
  37. include one git codebase as a subdirectory of another.
  38. Example of using a subtree for the ``editorconfig`` directory from the
  39. EditorConfig Python Core repository::
  40. git remote add -f editorconfig-core-py git://github.com/editorconfig/editorconfig-core-py.git
  41. git merge -s ours --no-commit editorconfig-core-py/master
  42. git read-tree --prefix=editorconfig -u editorconfig-core-py/master:editorconfig
  43. git commit
  44. For more information on subtrees consult the `subtree merge guide`_ on Github
  45. and `Chapter 6.7`_ in the book Pro Git.
  46. .. _`subtree merge guide`: http://help.github.com/subtree-merge/
  47. .. _`Chapter 6.7`: http://git-scm.com/book/ch6-7.html