Skip to content

Commit

Permalink
Format docs script
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Jun 12, 2024
1 parent 21d0921 commit 5ab63db
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions docs/api/error_table.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@

import av


rows = [(
#'Tag (Code)',
'Exception Class',
'Code/Enum Name',
'FFmpeg Error Message',
)]
rows = [("Exception Class", "Code/Enum Name", "FFmpeg Error Message")]

for code, cls in av.error.classes.items():

enum = av.error.ErrorType.get(code)

if not enum:
continue

if enum.tag == b'PyAV':
if enum.tag == b"PyAV":
continue

rows.append((
#'{} ({})'.format(enum.tag, code),
'``av.{}``'.format(cls.__name__),
'``av.error.{}``'.format(enum.name),
enum.strerror,
))
rows.append((f"``av.{cls.__name__}``", f"``av.error.{enum.name}``", enum.strerror))

lens = [max(len(row[i]) for row in rows) for i in range(len(rows[0]))]

header = tuple('=' * x for x in lens)
header = tuple("=" * x for x in lens)
rows.insert(0, header)
rows.insert(2, header)
rows.append(header)

for row in rows:
print(' '.join('{:{}s}'.format(cell, len_) for cell, len_ in zip(row, lens)))
print(" ".join("{:{}s}".format(cell, len_) for cell, len_ in zip(row, lens)))

0 comments on commit 5ab63db

Please sign in to comment.