Skip to content

Conversation

@cmarqu
Copy link
Contributor

@cmarqu cmarqu commented Aug 4, 2025

The logging setup and use of rich for tracebacks makes exceptions hard to read in CI:

[18:55:35] Fail: sphinx-adc-theme                    generate_sample_sites.py:80
           ╭── Traceback (most recent call last) ──╮                            
           │ /home/runner/work/sphinx-themes.org/s │                            
           │ phinx-themes.org/src/generate_sample_ │                            
           │ sites.py:78 in generate_site          │                            
           │                                       │                            
           │    75 │   │   │   │   " stderr ".cent │                            
           │    76 │   │   │   │   stderr.decode() │                            
           │    77 │   │   │   ]                   │                            
           │ ❱  78 │   │   │   raise Exception("\n │                            
           │    79 │   except Exception as e:      │                            
           │    80 │   │   progress.log(f"Fail: [r │                            
           │    81 │   │   destination_path.mkdir( │                            
           ╰───────────────────────────────────────╯                            

This PR sets COLUMNS to get a wider display. With a value of 120:

           Fail: sphinx-adc-theme                                                            generate_sample_sites.py:80
           ╭────────────────────── Traceback (most recent call last) ──────────────────────╮                            
           │ /home/runner/work/sphinx-themes.org/sphinx-themes.org/src/generate_sample_sit │                            
           │ es.py:78 in generate_site                                                     │                            
           │                                                                               │                            
           │    75 │   │   │   │   " stderr ".center(88, "="),                             │                            
           │    76 │   │   │   │   stderr.decode(),                                        │                            
           │    77 │   │   │   ]                                                           │                            
           │ ❱  78 │   │   │   raise Exception("\n".join(message))                         │                            
           │    79 │   except Exception as e:                                              │                            
           │    80 │   │   progress.log(f"Fail: [red]{theme.name}[reset]", rich.traceback. │                            
           │    81 │   │   destination_path.mkdir(parents=True, exist_ok=True)             │                            
           ╰───────────────────────────────────────────────────────────────────────────────╯                            

Should we go even wider?

@stevepiercy
Copy link
Contributor

I'd go with 160, based on this string, including the indentation and line feeds rich throws into the output.

           "/home/runner/work/sphinx-themes.org/sphi                            
           nx-themes.org/.nox/publish/lib/python3.12                            
           /site-packages/sphinx/builders/__init__.p                            
           y", line 749, in write_documents                                     

I don't know why it excessively indents and hard wraps tracebacks, which makes it less useful. Are there options to turn those off? I think that would be the better option.

@cmarqu
Copy link
Contributor Author

cmarqu commented Aug 5, 2025

For tracebacks, it sounds like word_wrap should be set at least, and maybe we also need width (though that might be derived from COLUMNS): https://rich.readthedocs.io/en/stable/reference/traceback.html

@stevepiercy
Copy link
Contributor

word_wrap defaults to False, so I think it's fine to leave it as is. width smells like the right option to override. 100 is too low. I might also try indent_guides=False.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants