Skip to content

Commit

Permalink
Finish docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Moosems committed Jul 24, 2024
1 parent 86376ef commit d70ea51
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
9 changes: 7 additions & 2 deletions docs/source/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Classes
=======

As it's very early on in its life ``Albero`` does not have many classes to utilize. It does, howver have one main class that handles all the main logic.

.. _TreeSitterHighlighter Overview:

``TreeSitterHighlighter``
Expand All @@ -18,3 +16,10 @@ The ``TreeSitterHighlighter`` is a class that provides the following methods for
- ``TreeSitterHighlighter.get_highlights(self, file_name: str, text_range: tuple[int, int] = (1, -1)) -> list[Token]`` (text range is inclusive of lines given and a -1 in the second position marks to go till the end of the file
- ``TreeSitterHighlighter.remove_file(self, file_name: str) -> None``
- ``TreeSitterHighlighter.remove_language(self, language_name: str) -> None``

.. _AlberoException Overview:

``AlberoException``
*******************

The ``AlberoException`` class is a simple ``Exception`` subclass for ``Albero``
21 changes: 21 additions & 0 deletions docs/source/functions.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
=========
Functions
=========

.. _lang_from_so Overview:

``lang_from_so(path: str | pathlib.Path, name: str) -> tree_sitter.Language``
*****************************************************************************

This function takes a ``.so`` file and the language name (used by the old tree sitter versions) and returns a ``tree_sitter.Language`` for usage with Albero.

.. _get_lang Overview:

``get_lang(language_name: str) -> tree_sitter.Language``
********************************************************

Takes a language name and attempts to get a ``tree_sitter.Language`` from the dict of builtin Tree Sitter languages.

.. _get_mapping Overview:

``get_mapping(language_name: str) -> dict[str, str]``
*****************************************************

Takes a language name and attempts to get a mapping from the dict of pre-made mappings.
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
``Albero`` Documentation
========================

Welcome to ``Albero``'s Documentation! ``Albero`` is a library that can be used by code editors to easily get tree sitter syntax highlighting while doing this with the simplest API I could imagine for this while remaining very powerful . To get started with Albero, visit the :doc:`installation` page!
Welcome to ``Albero``'s Documentation! ``Albero`` is a library that can be used by code editors to easily get Tree Sitter based syntax highlighting while doing this with the simplest API I could imagine for this while remaining very powerful . To get started with Albero, visit the :doc:`installation` page!

.. note::

Expand Down
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ To start using ``Albero``, first install it using pip:
$ pip install albero
And it's installed! Congratulations on giving your code editors syntax highlighting and allowing yourself to not pull out hair in the process!
And it's installed! Congratulations on giving your code editors Tree Sitter based syntax highlighting and allowing yourself to not pull out hair in the process!

Let's move on to the :doc:`example-usage` page to give ``Albero`` a try!
16 changes: 16 additions & 0 deletions docs/source/variables.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
=========
Variables
=========

.. _Token Overview:

``Token``
*********

The ``Token`` type is, in reality, just a type alias of ``tuple[tuple[int, int], int, str]``. Despite simply being a ``tuple``, the ``Token`` is the most frequently returned data type. That being said, what data does it signify?

The ``Token`` type contains three parts: the start index, its length, and its type. The start index is that ``tuple`` at the beginning of the main ``tuple`` and the first index of that is the line the ``Token`` takes place on and the second is the column. ``Token``'s start at index ``1, 0`` so you may need to do a -1 or a +1 depending on how you need to use this data. The second ``int`` is the length of the ``Token` and the ``str`` is the type. You will use these very often so its never a bad idea to get familiar with them.

.. _Generic Tokens Overview:

``generic_tokens``
******************

The ``generic_tokens`` ``list`` provides all the generic ``Token`` types you will encounter when using ``Salve``. Simply print this out and you will know all possible ``Token`` types you will be working with when using ``Salve`` and yoiu will never be surprised by a random ``Token`` type.

0 comments on commit d70ea51

Please sign in to comment.