xref: /aosp_15_r20/external/fonttools/Doc/README.md (revision e1fe3e4ad2793916b15cccdc4a7da52a7e1dd0e9)
1*e1fe3e4aSElliott Hughes# fontTools Documentation
2*e1fe3e4aSElliott Hughes
3*e1fe3e4aSElliott HughesThe fontTools project documentation updates continuously on Read the Docs as the project source changes.
4*e1fe3e4aSElliott Hughes
5*e1fe3e4aSElliott HughesThe documentation is hosted at https://fonttools.readthedocs.io/.
6*e1fe3e4aSElliott Hughes
7*e1fe3e4aSElliott Hughes## Contents
8*e1fe3e4aSElliott Hughes
9*e1fe3e4aSElliott Hughes- [How to Build Local Documentation](#how-to-build-local-documentation)
10*e1fe3e4aSElliott Hughes- [Contributing to the fontTools Documentation](#contributing-to-the-documentation)
11*e1fe3e4aSElliott Hughes- [Documentation License](#documentation-license)
12*e1fe3e4aSElliott Hughes
13*e1fe3e4aSElliott Hughes## How to Build Local Documentation
14*e1fe3e4aSElliott Hughes
15*e1fe3e4aSElliott Hughes### Install Dependencies
16*e1fe3e4aSElliott Hughes
17*e1fe3e4aSElliott HughesYou must have a Python 3 interpreter and the `pip` Python package manager installed on your system to build the fontTools documentation.
18*e1fe3e4aSElliott Hughes
19*e1fe3e4aSElliott HughesPull the fontTools project source files, create a Python virtual environment, and then install fontTools and the documentation build dependencies by executing the following commands in the root of the fontTools source repository:
20*e1fe3e4aSElliott Hughes
21*e1fe3e4aSElliott Hughes```
22*e1fe3e4aSElliott Hughes$ pip install -e .[all]
23*e1fe3e4aSElliott Hughes$ pip install -r Doc/docs-requirements.txt
24*e1fe3e4aSElliott Hughes```
25*e1fe3e4aSElliott Hughes
26*e1fe3e4aSElliott Hughes### Build Documentation
27*e1fe3e4aSElliott Hughes
28*e1fe3e4aSElliott Hughes**With `make`**: execute the following command in the root of the repository:
29*e1fe3e4aSElliott Hughes
30*e1fe3e4aSElliott Hughes```
31*e1fe3e4aSElliott Hughes$ make docs
32*e1fe3e4aSElliott Hughes```
33*e1fe3e4aSElliott Hughes
34*e1fe3e4aSElliott Hughes**Without `make`**: execute the following command in the **`Doc` directory**:
35*e1fe3e4aSElliott Hughes
36*e1fe3e4aSElliott Hughes```
37*e1fe3e4aSElliott Hughes$ sphinx-build -b html source build
38*e1fe3e4aSElliott Hughes```
39*e1fe3e4aSElliott Hughes
40*e1fe3e4aSElliott HughesOpen the `Doc/build/html/index.html` file in your browser to view the documentation home page.
41*e1fe3e4aSElliott Hughes
42*e1fe3e4aSElliott Hughes## Contributing to the Documentation
43*e1fe3e4aSElliott Hughes
44*e1fe3e4aSElliott HughesWe highly encourage contributions!  Please follow the instructions below to improve the documentation.
45*e1fe3e4aSElliott Hughes
46*e1fe3e4aSElliott Hughes### Python Docstring Style
47*e1fe3e4aSElliott Hughes
48*e1fe3e4aSElliott HughesWe recommend the use of Python docstrings that follow [the Google Style Guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md#381-docstrings).  Our documentation build approach parses appropriately formatted docstrings into formatted documentation files.
49*e1fe3e4aSElliott Hughes
50*e1fe3e4aSElliott Hughes#### Function Documentation Example
51*e1fe3e4aSElliott Hughes
52*e1fe3e4aSElliott Hughes```python
53*e1fe3e4aSElliott Hughesdef fetch_bigtable_rows(big_table, keys, other_silly_variable=None):
54*e1fe3e4aSElliott Hughes    """Fetches rows from a Bigtable.
55*e1fe3e4aSElliott Hughes
56*e1fe3e4aSElliott Hughes    Retrieves rows pertaining to the given keys from the Table instance
57*e1fe3e4aSElliott Hughes    represented by big_table.  Silly things may happen if
58*e1fe3e4aSElliott Hughes    other_silly_variable is not None.
59*e1fe3e4aSElliott Hughes
60*e1fe3e4aSElliott Hughes    Args:
61*e1fe3e4aSElliott Hughes        big_table: An open Bigtable Table instance.
62*e1fe3e4aSElliott Hughes        keys: A sequence of strings representing the key of each table row
63*e1fe3e4aSElliott Hughes            to fetch.
64*e1fe3e4aSElliott Hughes        other_silly_variable: Another optional variable, that has a much
65*e1fe3e4aSElliott Hughes            longer name than the other args, and which does nothing.
66*e1fe3e4aSElliott Hughes
67*e1fe3e4aSElliott Hughes    Returns:
68*e1fe3e4aSElliott Hughes        A dict mapping keys to the corresponding table row data
69*e1fe3e4aSElliott Hughes        fetched. Each row is represented as a tuple of strings. For
70*e1fe3e4aSElliott Hughes        example:
71*e1fe3e4aSElliott Hughes
72*e1fe3e4aSElliott Hughes        {'Serak': ('Rigel VII', 'Preparer'),
73*e1fe3e4aSElliott Hughes         'Zim': ('Irk', 'Invader'),
74*e1fe3e4aSElliott Hughes         'Lrrr': ('Omicron Persei 8', 'Emperor')}
75*e1fe3e4aSElliott Hughes
76*e1fe3e4aSElliott Hughes        If a key from the keys argument is missing from the dictionary,
77*e1fe3e4aSElliott Hughes        then that row was not found in the table.
78*e1fe3e4aSElliott Hughes
79*e1fe3e4aSElliott Hughes    Raises:
80*e1fe3e4aSElliott Hughes        IOError: An error occurred accessing the bigtable.Table object.
81*e1fe3e4aSElliott Hughes    """
82*e1fe3e4aSElliott Hughes```
83*e1fe3e4aSElliott Hughes*Source: [Google Style Guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md) (CC BY-SA 3.0)*
84*e1fe3e4aSElliott Hughes
85*e1fe3e4aSElliott Hughes#### Class Documentation Example
86*e1fe3e4aSElliott Hughes
87*e1fe3e4aSElliott Hughes```python
88*e1fe3e4aSElliott Hughesclass SampleClass(object):
89*e1fe3e4aSElliott Hughes    """Summary of class here.
90*e1fe3e4aSElliott Hughes
91*e1fe3e4aSElliott Hughes    Longer class information....
92*e1fe3e4aSElliott Hughes    Longer class information....
93*e1fe3e4aSElliott Hughes
94*e1fe3e4aSElliott Hughes    Attributes:
95*e1fe3e4aSElliott Hughes        likes_spam: A boolean indicating if we like SPAM or not.
96*e1fe3e4aSElliott Hughes        eggs: An integer count of the eggs we have laid.
97*e1fe3e4aSElliott Hughes    """
98*e1fe3e4aSElliott Hughes
99*e1fe3e4aSElliott Hughes    def __init__(self, likes_spam=False):
100*e1fe3e4aSElliott Hughes        """Inits SampleClass with blah."""
101*e1fe3e4aSElliott Hughes        self.likes_spam = likes_spam
102*e1fe3e4aSElliott Hughes        self.eggs = 0
103*e1fe3e4aSElliott Hughes
104*e1fe3e4aSElliott Hughes    def public_method(self):
105*e1fe3e4aSElliott Hughes        """Performs operation blah."""
106*e1fe3e4aSElliott Hughes```
107*e1fe3e4aSElliott Hughes*Source: [Google Style Guide](https://github.com/google/styleguide/blob/gh-pages/pyguide.md) (CC BY-SA 3.0)*
108*e1fe3e4aSElliott Hughes
109*e1fe3e4aSElliott Hughes### Build Local Documentation and Review Your Changes
110*e1fe3e4aSElliott Hughes
111*e1fe3e4aSElliott HughesBuild a local set of HTML documentation files with the instructions above and review your changes.
112*e1fe3e4aSElliott Hughes
113*e1fe3e4aSElliott Hughes### Submit a Pull Request
114*e1fe3e4aSElliott Hughes
115*e1fe3e4aSElliott HughesSubmit a Github pull request with your proposed improvements to the documentation.
116*e1fe3e4aSElliott Hughes
117*e1fe3e4aSElliott HughesThanks for your contribution!
118*e1fe3e4aSElliott Hughes
119*e1fe3e4aSElliott Hughes## Documentation License
120*e1fe3e4aSElliott Hughes
121*e1fe3e4aSElliott HughesThe fontTools documentation is released under a [CC BY-SA 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/).
122