Skip to content

Commit 80d341b

Browse files
Docs: Line wrap long lines of text for a display (#1140)
* Line wrap long lines of text for a display * Auto wraps lines of text in the docstrings for the schema docs. Lines are wrapped to 100 characters. * Update doc files * Fix incorrect documentation * Update src/py-opentimelineio/opentimelineio/console/autogen_serialized_datamodel.py * Fix lint errors Signed-off-by: Thomas Wilshaw <thomaswilshaw@gmail.com>
1 parent d0133d1 commit 80d341b

2 files changed

Lines changed: 54 additions & 16 deletions

File tree

docs/tutorials/otio-serialized-schema.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ Adapters convert between OTIO and other formats.
4444
to OTIO. You should not need to extend this class to create new adapters
4545
for OTIO.
4646
47-
For more information: https://opentimelineio.readthedocs.io/en/latest/tutorials/write-an-adapter.html. # noqa
47+
For more information: https://opentimelineio.readthedocs.io/en/latest/tutorials/write-an-
48+
adapter.html. # noqa
4849
4950
```
5051

@@ -63,7 +64,8 @@ parameters:
6364

6465
```
6566
66-
An object that can be composed within a :class:`~Composition` (such as :class:`~Track` or :class:`.Stack`).
67+
An object that can be composed within a :class:`~Composition` (such as :class:`~Track` or
68+
:class:`.Stack`).
6769
6870
```
6971

@@ -392,13 +394,21 @@ parameters:
392394

393395
```
394396
395-
An ImageSequenceReference refers to a numbered series of single-frame image files. Each file can be referred to by a URL generated by the :class:`~ImageSequenceReference`.
397+
An ImageSequenceReference refers to a numbered series of single-frame image files. Each file can be
398+
referred to by a URL generated by the :class:`~ImageSequenceReference`.
396399
397-
Image sequences can have URLs with discontinuous frame numbers, for instance if you've only rendered every other frame in a sequence, your frame numbers may be 1, 3, 5, etc. This is configured using the ``frame_step`` attribute. In this case, the 0th image in the sequence is frame 1 and the 1st image in the sequence is frame 3. Because of this there are two numbering concepts in the image sequence, the image number and the frame number.
400+
Image sequences can have URLs with discontinuous frame numbers, for instance if you've only rendered
401+
every other frame in a sequence, your frame numbers may be 1, 3, 5, etc. This is configured using
402+
the ``frame_step`` attribute. In this case, the 0th image in the sequence is frame 1 and the 1st
403+
image in the sequence is frame 3. Because of this there are two numbering concepts in the image
404+
sequence, the image number and the frame number.
398405
399-
Frame numbers are the integer numbers used in the frame file name. Image numbers are the 0-index based numbers of the frames available in the reference. Frame numbers can be discontinuous, image numbers will always be zero to the total count of frames minus 1.
406+
Frame numbers are the integer numbers used in the frame file name. Image numbers are the 0-index
407+
based numbers of the frames available in the reference. Frame numbers can be discontinuous, image
408+
numbers will always be zero to the total count of frames minus 1.
400409
401-
An example for 24fps media with a sample provided each frame numbered 1-1000 with a path ``/show/sequence/shot/sample_image_sequence.%04d.exr`` might be
410+
An example for 24fps media with a sample provided each frame numbered 1-1000 with a path
411+
``/show/sequence/shot/sample_image_sequence.%04d.exr`` might be
402412
403413
.. code-block:: json
404414
@@ -446,13 +456,15 @@ The same duration sequence but with only every 2nd frame available in the sequen
446456
"frame_zero_padding": 4,
447457
}
448458
449-
A list of all the frame URLs in the sequence can be generated, regardless of frame step, with the following list comprehension
459+
A list of all the frame URLs in the sequence can be generated, regardless of frame step, with the
460+
following list comprehension
450461
451462
.. code-block:: python
452463
453464
[ref.target_url_for_image_number(i) for i in range(ref.number_of_images_in_sequence())]
454465
455-
Negative ``start_frame`` is also handled. The above example with a ``start_frame`` of ``-1`` would yield the first three target urls as:
466+
Negative ``start_frame`` is also handled. The above example with a ``start_frame`` of ``-1`` would
467+
yield the first three target urls as:
456468
457469
- ``file:///show/sequence/shot/sample_image_sequence.-0001.exr``
458470
- ``file:///show/sequence/shot/sample_image_sequence.0000.exr``
@@ -504,9 +516,11 @@ Instead it affects the speed of the media displayed within that item.
504516

505517
```
506518
507-
A marker indicates a marked range of time on an item in a timeline, usually with a name, color or other metadata.
519+
A marker indicates a marked range of time on an item in a timeline, usually with a name, color or
520+
other metadata.
508521
509-
The marked range may have a zero duration. The marked range is in the owning item's time coordinate system.
522+
The marked range may have a zero duration. The marked range is in the owning item's time coordinate
523+
system.
510524
511525
```
512526

@@ -526,7 +540,8 @@ parameters:
526540
527541
Represents media for which a concrete reference is missing.
528542
529-
Note that a :class:`~MissingReference` may have useful metadata, even if the location of the media is not known.
543+
Note that a :class:`~MissingReference` may have useful metadata, even if the location of the media
544+
is not known.
530545
531546
```
532547

@@ -544,13 +559,16 @@ parameters:
544559

545560
```
546561
547-
A container which can hold an ordered list of any serializable objects. Note that this is not a :class:`.Composition` nor is it :class:`.Composable`.
562+
A container which can hold an ordered list of any serializable objects. Note that this is not a
563+
:class:`.Composition` nor is it :class:`.Composable`.
548564
549-
This container approximates the concept of a bin - a collection of :class:`.SerializableObject`\s that do
565+
This container approximates the concept of a bin - a collection of :class:`.SerializableObject`\s
566+
that do
550567
not have any compositional meaning, but can serialize to/from OTIO correctly, with metadata and
551568
a named collection.
552569
553-
A :class:`~SerializableCollection` is useful for serializing multiple timelines, clips, or media references to a single file.
570+
A :class:`~SerializableCollection` is useful for serializing multiple timelines, clips, or media
571+
references to a single file.
554572
555573
```
556574

@@ -633,7 +651,8 @@ parameters:
633651
*documentation*:
634652

635653
```
636-
Represents a transition between the two adjacent items in a :class:`.Track`. For example, a cross dissolve or wipe.
654+
Represents a transition between the two adjacent items in a :class:`.Track`. For example, a cross
655+
dissolve or wipe.
637656
```
638657

639658
parameters:

src/py-opentimelineio/opentimelineio/console/autogen_serialized_datamodel.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import json
1212
import tempfile
1313
import sys
14+
import textwrap
1415

1516
import io
1617

@@ -292,11 +293,29 @@ def _write_documentation(model):
292293
for cl in sorted(modules[module_list], key=lambda cl: str(cl)):
293294
modname = this_mod
294295
label = model[cl]["OTIO_SCHEMA"]
296+
297+
if (cl.__doc__ is not None):
298+
docstring = cl.__doc__.split("\n")
299+
new_docstring = []
300+
for line in docstring:
301+
line = textwrap.wrap(line, width=100,
302+
expand_tabs=False,
303+
replace_whitespace=False,
304+
drop_whitespace=False,
305+
break_long_words=False)
306+
if (line == []):
307+
line = [""]
308+
for wrapped_line in line:
309+
new_docstring.append(wrapped_line)
310+
new_docstring = "\n".join(new_docstring)
311+
else:
312+
new_docstring = cl.__doc__
313+
295314
md_with_helpstrings.write(
296315
CLASS_HEADER_WITH_DOCS.format(
297316
classname=label,
298317
modpath=modname + "." + cl.__name__,
299-
docstring=cl.__doc__
318+
docstring=new_docstring
300319
)
301320
)
302321
md_only_fields.write(

0 commit comments

Comments
 (0)