Skip to content

Commit d421ce1

Browse files
authoredMay 20, 2020
Update READMEs and add documentation for fluent.pygments (#148)
Our READMEs on the fluent packages are lacking. Create some, and use them in setup.py to add better content on pypi. Also convert to restructuredText to align with rest of docs. The documentation for fluent.pygments is really just to demo the highlighting.
1 parent e5dbc41 commit d421ce1

File tree

14 files changed

+201
-89
lines changed

14 files changed

+201
-89
lines changed
 

‎.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.tox
2+
.vscode
23
*.pyc
34
.eggs/
45
*.egg-info/
56
_build
7+
build
8+
dist

‎README.md

-79
This file was deleted.

‎README.rst

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Project Fluent
2+
==============
3+
4+
This is a collection of Python packages to use the `Fluent localization
5+
system <http://projectfluent.org/>`__.
6+
7+
python-fluent consists of these packages:
8+
9+
``fluent.syntax``
10+
-----------------
11+
12+
The `syntax package <fluent.syntax>`_ includes the parser, serializer, and traversal
13+
utilities like Visitor and Transformer. You’re looking for this package
14+
if you work on tooling for Fluent in Python.
15+
16+
``fluent.runtime``
17+
------------------
18+
19+
The `runtime package <fluent.runtime>`__ includes the library required to use Fluent to localize
20+
your Python application. It comes with a ``Localization`` class to use,
21+
based on an implementation of ``FluentBundle``. It uses the tooling parser above
22+
to read Fluent files.
23+
24+
``fluent.pygments``
25+
-------------------
26+
27+
A `plugin for pygments <fluent.pygments>`_ to add syntax highlighting to Sphinx.
28+
29+
Discuss
30+
-------
31+
32+
We’d love to hear your thoughts on Project Fluent! Whether you’re a
33+
localizer looking for a better way to express yourself in your language,
34+
or a developer trying to make your app localizable and multilingual, or
35+
a hacker looking for a project to contribute to, please do get in touch
36+
on the mailing list and the IRC channel.
37+
38+
- Mozilla Discourse: https://discourse.mozilla.org/c/fluent
39+
- Matrix channel:
40+
`#fluent:mozilla.org <https://chat.mozilla.org/#/room/#fluent:mozilla.org>`__
41+
42+
Get Involved
43+
------------
44+
45+
python-fluent is open-source, licensed under the Apache License, Version
46+
2.0. We encourage everyone to take a look at our code and we’ll listen
47+
to your feedback.

‎docs/index.rst

+10-3
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,31 @@ python-fluent
55
The :py:mod:`python-fluent` project contains several packages to
66
bring `Project Fluent <https://projectfluent.org>`__ to Python.
77
Visit the `Github project <https://github.com/projectfluent/python-fluent>`__
8-
for the full list. Two packages in particular are of general interest
8+
for the full list. Three packages in particular are of general interest
99
and documented here.
1010

1111
fluent.syntax
1212
-------------
1313

14-
``fluent-syntax`` is the package to use for tooling, analysis, and
14+
``fluent.syntax`` is the package to use for tooling, analysis, and
1515
processing of Fluent files.
1616

1717
fluent.runtime
1818
--------------
1919

20-
``fluent-runtime`` is the reference runtime implementation for
20+
``fluent.runtime`` is the reference runtime implementation for
2121
Fluent in Python.
2222

23+
fluent.pygments
24+
---------------
25+
26+
``fluent.pygments`` can be used to add syntax highlighting for
27+
Fluent files to Sphinx documentation.
28+
2329
.. toctree::
2430
:caption: Packages
2531
:maxdepth: 1
2632

2733
fluent.syntax <https://projectfluent.org/python-fluent/fluent.syntax/>
2834
fluent.runtime <https://projectfluent.org/python-fluent/fluent.runtime/>
35+
fluent.pygments <https://projectfluent.org/python-fluent/fluent.pygments/>

‎fluent.pygments/README.rst

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
fluent.pygments
2+
===============
3+
4+
A plugin for pygments to add `Fluent`_ syntax highlighting to Sphinx.
5+
6+
Installation
7+
------------
8+
9+
.. code-block:: bash
10+
11+
pip install fluent.pygments
12+
13+
14+
Usage
15+
-----
16+
17+
.. code-block:: rst
18+
19+
20+
.. code-block:: fluent
21+
22+
my-message = a localized string
23+
24+
25+
The `documentation`_ has an example of Fluent content
26+
highlighted with ``fluent.pygments``.
27+
28+
.. _fluent: https://projectfluent.org/
29+
.. _documentation: https://projectfluent.org/python-fluent/fluent.pygments

‎fluent.pygments/docs/index.rst

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
Fluent Syntax Highlighting
2+
==========================
3+
4+
The :py:mod:`fluent.pygments` library is built to do syntax highlighting
5+
for `Fluent`_ files in Sphinx.
6+
7+
8+
Installation
9+
------------
10+
11+
.. code-block:: bash
12+
13+
pip install fluent.pygments
14+
15+
16+
Usage
17+
-----
18+
19+
.. code-block:: rst
20+
21+
22+
.. code-block:: fluent
23+
24+
my-key = Localize { -brand-name }
25+
26+
Example
27+
-------
28+
29+
.. code-block:: fluent
30+
31+
### A resource comment for the whole file
32+
33+
my-key = Localize { -brand-name }
34+
-brand-name = Fluent
35+
36+
# $num is the number of strings to localize
37+
plurals = { $num ->
38+
[one] One string
39+
*[other] {$num} strings
40+
}
41+
an error ;-)
42+
Most-strings = are just simple strings.
43+
44+
.. _fluent: https://projectfluent.org/

‎fluent.pygments/setup.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
[metadata]
2+
version=0.1.0
3+
14
[bdist_wheel]
25
universal=1
36

‎fluent.pygments/setup.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
#!/usr/bin/env python
22
from setuptools import setup
3+
import os
4+
5+
this_directory = os.path.abspath(os.path.dirname(__file__))
6+
with open(os.path.join(this_directory, 'README.rst'), 'rb') as f:
7+
long_description = f.read().decode('utf-8')
38

49
setup(name='fluent.pygments',
5-
version='0.1.0',
610
description='Pygments lexer for Fluent.',
7-
long_description='See https://github.com/projectfluent/python-fluent/ for more info.',
11+
long_description=long_description,
12+
long_description_content_type='text/x-rst',
813
author='Mozilla',
914
author_email='l10n-drivers@mozilla.org',
1015
license='APL 2',
@@ -20,4 +25,4 @@
2025
packages=['fluent', 'fluent.pygments'],
2126
tests_require=['six'],
2227
test_suite='tests.pygments'
23-
)
28+
)

‎fluent.runtime/README.rst

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
fluent.runtime |fluent.runtime|
2+
===============================
3+
4+
Use `Fluent`_ to localize your Python application. It comes with a ``Localization``
5+
class to use, based on an implementation of ``FluentBundle``. It uses the parser from
6+
``fluent.syntax`` to read Fluent files.
7+
8+
.. code-block:: python
9+
10+
>>> from datetime import date
11+
>>> l10n = DemoLocalization("today-is = Today is { $today }")
12+
>>> val = l10n.format_value("today-is", {"today": date.today() })
13+
>>> val
14+
'Today is Jun 16, 2018'
15+
16+
Find the full documentation on https://projectfluent.org/python-fluent/fluent.runtime/.
17+
18+
.. _fluent: https://projectfluent.org/
19+
.. |fluent.runtime| image:: https://github.com/projectfluent/python-fluent/workflows/fluent.runtime/badge.svg

‎fluent.runtime/docs/usage.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ passed through locale aware functions:
153153
154154
>>> from datetime import date
155155
>>> l10n = DemoLocalization("today-is = Today is { $today }")
156-
>>> val = bundle.format_value("today-is", {"today": date.today() })
156+
>>> val = l10n.format_value("today-is", {"today": date.today() })
157157
>>> val
158158
'Today is Jun 16, 2018'
159159

‎fluent.runtime/setup.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
#!/usr/bin/env python
22
from setuptools import setup
3+
import os
4+
5+
this_directory = os.path.abspath(os.path.dirname(__file__))
6+
with open(os.path.join(this_directory, 'README.rst'), 'rb') as f:
7+
long_description = f.read().decode('utf-8')
38

49

510
setup(name='fluent.runtime',
611
description='Localization library for expressive translations.',
7-
long_description='See https://github.com/projectfluent/python-fluent/ for more info.',
12+
long_description=long_description,
13+
long_description_content_type='text/x-rst',
814
author='Luke Plant',
915
author_email='L.Plant.98@cantab.net',
1016
license='APL 2',

‎fluent.syntax/README.rst

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
``fluent.syntax`` |fluent.syntax|
2+
---------------------------------
3+
4+
Read, write, and transform `Fluent`_ files.
5+
6+
This package includes the parser, serializer, and traversal
7+
utilities like Visitor and Transformer. You’re looking for this package
8+
if you work on tooling for Fluent in Python.
9+
10+
.. code-block:: python
11+
12+
>>> from fluent.syntax import parse, ast, serialize
13+
>>> resource = parse("a-key = String to localize")
14+
>>> resource.body[0].value.elements[0].value = "Localized string"
15+
>>> serialize(resource)
16+
'a-key = Localized string\n'
17+
18+
19+
Find the full documentation on https://projectfluent.org/python-fluent/fluent.syntax/.
20+
21+
.. _fluent: https://projectfluent.org/
22+
.. |fluent.syntax| image:: https://github.com/projectfluent/python-fluent/workflows/fluent.syntax/badge.svg

‎fluent.syntax/setup.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
#!/usr/bin/env python
22
from setuptools import setup
3+
import os
4+
5+
this_directory = os.path.abspath(os.path.dirname(__file__))
6+
with open(os.path.join(this_directory, 'README.rst'), 'rb') as f:
7+
long_description = f.read().decode('utf-8')
38

49
setup(name='fluent.syntax',
510
description='Localization library for expressive translations.',
6-
long_description='See https://github.com/projectfluent/python-fluent/ for more info.',
11+
long_description=long_description,
12+
long_description_content_type='text/x-rst',
713
author='Mozilla',
814
author_email='l10n-drivers@mozilla.org',
915
license='APL 2',

‎scripts/build-docs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if __name__ == "__main__":
6969
'--to-publish', dest='pre_pub', action='store_true',
7070
help='Use this to publish to Github. Builds faster without.'
7171
)
72-
default_docs = ['.', 'fluent.syntax', 'fluent.runtime']
72+
default_docs = ['.', 'fluent.syntax', 'fluent.pygments', 'fluent.runtime']
7373
parser.add_argument(
7474
'--doc', action='append', choices=default_docs,
7575
help='Only build select documentation roots.'

0 commit comments

Comments
 (0)
Please sign in to comment.