Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Explicit summary directive alignment #82

Closed
vepain opened this issue Nov 8, 2022 · 6 comments
Closed

[FEATURE] Explicit summary directive alignment #82

vepain opened this issue Nov 8, 2022 · 6 comments

Comments

@vepain
Copy link

vepain commented Nov 8, 2022

Now behaviour

When autosummary is used as a directive and not as a directive option, the alignment of the table is centered.

Example

- For :data:`OrT` type:

.. autosummary::

    FORWARD_INT
    REVERSE_INT
    ORIENT_REV
    FWDOR_REVOR


- For :data:`IndOrT` type:

.. autosummary::

    IND
    OR

gives Capture d’écran de 2022-11-08 18-24-29

Asked feature

Is it possible to left-align the table, for example, with an option under autosummary directive please?

Versions

  • python 3.9.5
  • sphinx 5.3.0
  • autodocsumm 0.2.9
  • furo 2022.9.29

Thank you for your work!

@Chilipp
Copy link
Owner

Chilipp commented Nov 8, 2022

hey @vepain! thanks for your input! I am not sure about this. Wouldn't this be something that is configured by the sphinx template that you use? you could add some custom css, here is an example: https://docs.readthedocs.io/en/stable/guides/adding-custom-css.html

@vepain
Copy link
Author

vepain commented Nov 9, 2022

Thank you @Chilipp for your answer!

It seems that only a few customisations are allowed by furo theme (see https://pradyunsg.me/furo/customisation/).

Moreover, it seems that tables are centered by default by Sphinx, and I can't find a way to align local table not by default (see sphinx-doc/sphinx#4550)
In the html source file, the tables produced by .. autosummary:: directive are under the following class:

<table class="autosummary longtable docutils align-default">
...
</table>

Here the align-default key seems to be the issue.

Why not allow for one .. autosummary:: directive detail the table alignment like this?

.. autosummary::

    :alig: left
    
    ...

that would produce something like this:

<table class="autosummary longtable docutils align-left">
...
</table>

I don't have enough CSS and HTML knowledge, so perhaps I miss some points.
The idea is not to change the align-default (that will change all the alignment globally).
And even though I wanted to do this, I can't find in Sphinx doc a way to change the default table alignment.

Thank you for your help!

@vepain
Copy link
Author

vepain commented Nov 9, 2022

Sorry for the second message,

I find https://docutils.sourceforge.io/docs/ref/rst/directives.html#tables where the directive .. table:: has the option :align: left (e.g.)

Why not get inspired of that for the table generation of .. autosummary:: directive?

@Chilipp
Copy link
Owner

Chilipp commented Nov 9, 2022

the problem here @vepain is that the .. autosummary directive that is used here does not come from the autodocsumm extension. it is coming from the builtin sphinx extension autosummary. autodocsumm is just using this directive. So if you want to change anything on the underlying autosummary directive, you'd need to head over to the main sphinx repo at https://github.com/sphinx-doc/sphinx/ and open an issue there. When this option is implemented, in autosummary, we can add an additional option here

@Chilipp
Copy link
Owner

Chilipp commented Nov 9, 2022

my suggestion would have been to add a custom css file

html_css_files = [
    'css/custom.css',
]

and then in custom.css have something like

table.autosummary {
    /** add some alignment css here **/
}

@vepain
Copy link
Author

vepain commented Nov 9, 2022

My bad, I confused your extension with the sphinx builtin.
Thank you for your help, I will write an issue at the right place...
Have a nice day!

@Chilipp Chilipp closed this as completed Jan 15, 2023
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

No branches or pull requests

2 participants