File: index.rst

package info (click to toggle)
python-baron 0.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,080 kB
  • sloc: python: 26,926; makefile: 126; sh: 27
file content (106 lines) | stat: -rw-r--r-- 3,009 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Welcome to Baron's documentation!
=================================

Introduction
------------

Baron is a Full Syntax Tree (FST) for Python. It represents source code
as a structured tree, easily parsable by a computer. By opposition to
an `Abstract Syntax Tree
<http://en.wikipedia.org/wiki/Abstract_syntax_tree>`_ (AST) which drops
syntax information in the process of its creation (like empty lines,
comments, formatting), a FST keeps everything and guarantees the
operation :file:`fst_to_code(code_to_fst(source_code)) == source_code`.

If you want to understand why this is important, read this:
https://github.com/PyCQA/baron#why-is-this-important

Github (code, bug tracker, etc.)
--------------------------------

https://github.com/PyCQA/baron

Installation
------------

::

    pip install baron

RedBaron
--------

There is a good chance that you'll want to use `RedBaron
<https://redbaron.readthedocs.io>`_ instead of using Baron directly.
Think of Baron as the "bytecode of python source code" and RedBaron as
some sort of usable layer on top of it, a bit like dom/jQuery or
html/Beautifulsoup.

Basic usage
-----------

.. ipython:: python
    :suppress:

    import sys
    sys.path.append("..")

.. ipython:: python

    from baron import parse, dumps

    source_code = "a = 1"
    fst = parse(source_code)
    fst
    generated_source_code = dumps(fst)
    generated_source_code
    source_code == generated_source_code


Financial support
-----------------

Baron and RedBaron are a very advanced piece of engineering that requires a lot
of time of concentration to work on. Until the end of 2018, the development
has been a full volunteer work mostly done by [Bram](https://github.com/psycojoker),
but now, to reach the next level and bring those projects to the stability and
quality you expect, we need your support.

You can join our contributors and sponsors on our transparent
[OpenCollective](https://opencollective.com/redbaron), every contribution will
count and will be mainly used to work on the projects stability and quality but
also on continuing, on the side, the R&D side of those projects.

Our supporters
~~~~~~~~~~~~~~

.. image:: https://opencollective.com/redbaron/tiers/i-like-this,-keep-going!/badge.svg?label=I like this, keep going!&color=brightgreen
.. image:: https://opencollective.com/redbaron/tiers/it-looks-cool!/badge.svg?label=It looks cool!&color=brightgreen
.. image:: https://opencollective.com/redbaron/tiers/oh-god,-that-saved-me-so-much-time!/badge.svg?label=Oh god, that saved me so much time!&color=brightgreen

\

.. image:: https://opencollective.com/redbaron/tiers/i-like-this,-keep-going!.svg?avatarHeight=36&width=600

Become our first sponsor!

.. image:: https://opencollective.com/redbaron/tiers/long-term-sponsor.svg?avatarHeight=36&width=600

Table of content
----------------

.. toctree::
   :maxdepth: 2

   basics
   advanced
   technical


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`