Fix table alignment and consolidate callout boxes

- Fix 75 grid tables: ensure first column is always left-aligned
- Update format_tables.py to enforce left-aligned first column rule
- Update convert_pipe_to_grid_tables.py to enforce same rule
- Consolidate redundant callout boxes in ops, model_compression, serving, dl_primer
- Streamline napkin math sections for better flow
This commit is contained in:
Vijay Janapa Reddi
2026-01-24 12:24:33 -05:00
parent b90eaf277e
commit 843f536220
66 changed files with 6498 additions and 273 deletions

View File

@@ -123,6 +123,8 @@ def convert_to_grid_table(headers: List[str], alignments: List[str], data_rows:
This creates the basic grid structure. The format_tables.py script will
handle proper formatting, bolding, and alignment.
IMPORTANT: First column is ALWAYS left-aligned per book style guide.
"""
# Calculate column widths (basic - formatter will refine)
num_cols = len(headers)
@@ -133,6 +135,10 @@ def convert_to_grid_table(headers: List[str], alignments: List[str], data_rows:
if i < len(col_widths):
col_widths[i] = max(col_widths[i], len(cell))
# RULE: First column must ALWAYS be left-aligned (book style guide)
if alignments and alignments[0] != 'left':
alignments[0] = 'left'
# Build border line
def build_border():
parts = ['-' * (w + 2) for w in col_widths]
@@ -141,7 +147,10 @@ def convert_to_grid_table(headers: List[str], alignments: List[str], data_rows:
# Build separator line (with alignment markers)
def build_separator():
parts = []
for width, align in zip(col_widths, alignments):
for idx, (width, align) in enumerate(zip(col_widths, alignments)):
# Enforce first column left-alignment
if idx == 0:
align = 'left'
if align == 'center':
parts.append(':' + '=' * width + ':')
elif align == 'left':

View File

@@ -264,6 +264,7 @@ def detect_column_alignments(header_rows: List[List[str]], data_rows: List[List[
Detect optimal alignment for each column based on content.
Rules:
- FIRST COLUMN: Always left-aligned (book style guide requirement)
- Numeric columns (>70% numbers): right-aligned
- Text columns: left-aligned
- Mixed: left-aligned (default)
@@ -275,6 +276,11 @@ def detect_column_alignments(header_rows: List[List[str]], data_rows: List[List[
alignments = []
for col_idx in range(num_columns):
# RULE: First column is ALWAYS left-aligned (book style guide)
if col_idx == 0:
alignments.append('left')
continue
# Collect all values in this column (skip empty cells)
column_values = []
for row in data_rows:
@@ -689,6 +695,10 @@ def validate_table(parser: GridTableParser, max_width: Optional[int] = None) ->
"""
warnings = []
# Check first column alignment (must ALWAYS be left-aligned per style guide)
if parser.alignments and parser.alignments[0] != 'left':
warnings.append(f"First column must be left-aligned (found: {parser.alignments[0]})")
# Check header bolding (check ALL header rows for multiline headers)
unbolded_headers = []
for row_idx, header_row in enumerate(parser.header_rows):