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

docs: set maxdepth or titlesonly on overly-long TOCs #2558

Merged
merged 6 commits into from
Nov 21, 2023
Merged

Conversation

dgw
Copy link
Member

@dgw dgw commented Nov 12, 2023

Description

I set out to clean up some of the documentation appearance & make things more usable, taking into consideration the fact that we use the Furo theme now and detailed in-page TOCs are kinda redundant in a lot of places thanks to the dual sidebars.

In addition to the original impetus for this patch—maxdepth or titlesonly options on TOCs where needed—this patch also cleans up some warnings generated by SopelIdentifierMemory inheriting docstrings from dict, tells autodoc not to evaluate function argument defaults before display (eliminates <class 'sopel.foo.nonsense.ClassName'> from being shown, which is very ugly), and also improves the docstring of tools.get_sendable_message() because I don't want to open a tiny PR for that.

I'm also aware of what #2533 plans to change, and therefore avoided touching any of that PR's renamed/modified rST files at all. The comment in index.rst about adding install docs here is also gone; they're coming soon!

Checklist

  • I have read CONTRIBUTING.md
  • I can and do license this contribution under the EFLv2
  • No issues are reported by make qa (runs make lint and make test)
    • make test not so relevant, as no code changed; but I still ran make lint since I learned my lesson after skipping it earlier this week. 😅
  • I have tested the functionality of the things this change touches
    • Oh so many rebuilds… I'm as mad as I'll ever be now about those spurious :py:class: reference not found warnings we get from using type aliases for things like Casemapping or IdentifierFactory. Sphinx can't fix that soon enough.

@dgw dgw added Documentation Housekeeping Code cleanup, removal of deprecated stuff, etc. labels Nov 12, 2023
@dgw dgw added this to the 8.0.0 milestone Nov 12, 2023
@dgw dgw requested a review from a team November 12, 2023 00:51
Copy link
Contributor

@SnoopJ SnoopJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some nits, but overall LGTM

docs/source/index.rst Show resolved Hide resolved
docs/source/package/irc.rst Outdated Show resolved Hide resolved
docs/source/package/plugins.rst Outdated Show resolved Hide resolved
docs/source/package/tools.rst Show resolved Hide resolved
docs/source/tests.rst Show resolved Hide resolved
@dgw
Copy link
Member Author

dgw commented Nov 12, 2023

@SnoopJ "Back to you, Chet" to resolve or respond to the outstanding review conversations.

Copy link
Contributor

@SnoopJ SnoopJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoroughly de-nitted as far as I'm concerned :shipit:

Copy link
Contributor

@Exirel Exirel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! I don't like the :hidden: option however, I prefer to have just the lvl 1 titles displayed within the body, even tho it is already displayed on the left menu column. One of the practical reason for that: the menu bar is hidden by default on mobile, and that makes it a pain to navigate.

docs/source/package/config.rst Outdated Show resolved Hide resolved
docs/source/tests.rst Outdated Show resolved Hide resolved
@dgw
Copy link
Member Author

dgw commented Nov 15, 2023

I lack the energy to fight for using :hidden: in a few selected locations, so the win goes to @Exirel.

Latest branch update added a fix for Sphinx warnings about being unable to find :py:class:`datetime` in function signatures, as well. Now we have "only" 18 warnings (14 from that pesky issue with type aliases; 2 for internals of ast; and 2 for bad links to ssl.wrap_socket, which I might try to fix next also fixed).

Edit 5 mins later: wrap_socket warnings fixed. That was too easy. Down to 16 warnings now, which will have to do.

@dgw dgw requested a review from Exirel November 15, 2023 00:48
@Exirel
Copy link
Contributor

Exirel commented Nov 15, 2023

Sphinx warnings about being unable to find :py:class:datetime in function signatures

I hate you Sphinx. I really hate you.

Didn't touch the toctree in `run.rst` because the PR expanding Sphinx
install/run documentation already takes care of that one.

Was going to clean up some more stuff in `index.rst` but took those out
of this patch for the same reason: avoiding merge conflicts later.
Pointed to the "convenient" way of handling overlength messages via
optional arguments to `bot.say()`, but also cross-referenced the bot's
`safe_text_length(recipient)` method that returns the most useful value
for passing a `max_length` to `get_sendable_message()`, in case plugin
authors want to do something really fancy.
Without doing this, we get some very ugly Sphinx output for the class,
and a few cryptic warnings about missing "class" references that are
really just free-form text used in the CPython docs.
This is a supposedly "experimental" option that was added in Sphinx 4.0,
but here we are using Sphinx 7.1.x and it still hasn't been added to
autodoc core as planned.

Turning it on fixes the display of default parameters values like
`tools.memories._NO_DEFAULT` in function/method signatures.

Admittedly, I have not checked through the entire documentation set
again after enabling this, but it seems unlikely that there are ever
cases where we want the evaluated value to display instead of how it's
passed in the source code.
We have the choice of two not-great situations:

1. Concise `datetime` imports with broken cross-references in docs.
2. Verbose `datetime` imports with working cross-references in docs.

The ideal, of course, would be "Concise `datetime` imports with working
cross-references in docs", but this seems to be an impossibility at the
current time. Forced to choose between less-than-ideal alternatives, I
say we should pick the one that leads to better documentation. The cost
is cheap, at just 9 extra characters in each place where `plugins.rules`
references a type from sdlib's `datetime` module.
Just fixing a couple more Sphinx warnings. If only the warnings from
Sphinx always looking for "class" refs even when we use type aliases in
function/method signatures were this easy to solve.
@dgw dgw merged commit 3ff58c1 into master Nov 21, 2023
15 checks passed
@dgw dgw deleted the docs-toc-maxdepth branch November 21, 2023 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Housekeeping Code cleanup, removal of deprecated stuff, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants