Skip to content
Prev Previous commit
Next Next commit
syntax: Include py.typed, declare __all__
  • Loading branch information
eemeli committed Feb 11, 2023
commit cda9de605f266e02a546c112db4f574aa4225697
22 changes: 19 additions & 3 deletions fluent.syntax/fluent/syntax/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
from typing import Any
from .ast import Resource

from . import ast
from .errors import ParseError
from .parser import FluentParser
from .serializer import FluentSerializer
from .stream import FluentParserStream
from .visitor import Transformer, Visitor

__all__ = [
'FluentParser',
'FluentParserStream',
'FluentSerializer',
'ParseError',
'Transformer',
'Visitor',
'ast',
'parse',
'serialize'
]


def parse(source: str, **kwargs: Any) -> Resource:
def parse(source: str, **kwargs: Any) -> ast.Resource:
"""Create an ast.Resource from a Fluent Syntax source.
"""
parser = FluentParser(**kwargs)
return parser.parse(source)


def serialize(resource: Resource, **kwargs: Any) -> str:
def serialize(resource: ast.Resource, **kwargs: Any) -> str:
"""Serialize an ast.Resource to a unicode string.
"""
serializer = FluentSerializer(**kwargs)
Expand Down
Empty file.
11 changes: 6 additions & 5 deletions fluent.syntax/setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from setuptools import setup, find_namespace_packages
import os
from os import path
from setuptools import setup

this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, 'README.rst'), 'rb') as f:
this_directory = path.abspath(path.dirname(__file__))
with open(path.join(this_directory, 'README.rst'), 'rb') as f:
long_description = f.read().decode('utf-8')

setup(name='fluent.syntax',
Expand All @@ -24,6 +24,7 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3 :: Only',
],
packages=find_namespace_packages(include=['fluent.*']),
packages=['fluent.syntax'],
package_data={'fluent.syntax': ['py.typed']},
test_suite='tests.syntax'
)