Skip to content

[solvers] Shorten lengthy return types#23808

Merged
jwnimmer-tri merged 7 commits intoRobotLocomotion:masterfrom
j4yyousi:doxygen-layout-fix
Feb 23, 2026
Merged

[solvers] Shorten lengthy return types#23808
jwnimmer-tri merged 7 commits intoRobotLocomotion:masterfrom
j4yyousi:doxygen-layout-fix

Conversation

@j4yyousi
Copy link
Copy Markdown
Contributor

@j4yyousi j4yyousi commented Nov 19, 2025

Closes #18161, closes #11317.

Shorten lengthy return types to fix Doxygen's pages by:

  1. Migrating some function declarations from std::enable_if to requires
  2. Using trailing return types

This change is Reviewable

Effect of this PR on /doxygen_cxx/namespacedrake_1_1solvers.html #18161 :
Screenshot from 2025-11-19 21-34-34

Effect of this PR on /doxygen_cxx/classdrake_1_1solvers_1_1_mathematical_program.html #11317:
Screenshot from 2025-11-19 21-41-11

Shorten lengthy return types to fix Doxygen's pages by:
1) Migrating some declarations from `std::enable_if` to `requires`
2) Using trialing return types
@jwnimmer-tri jwnimmer-tri added the release notes: none This pull request should not be mentioned in the release notes label Nov 19, 2025
@jwnimmer-tri jwnimmer-tri self-assigned this Nov 19, 2025
@j4yyousi j4yyousi marked this pull request as ready for review November 19, 2025 19:26
Copy link
Copy Markdown
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

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

@jwnimmer-tri reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: 3 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers


solvers/non_convex_optimization_util.h line 166 at r1 (raw file):

    -> std::tuple<Binding<LinearConstraint>,
                  std::vector<Binding<RotatedLorentzConeConstraint>>,
                  VectorXDecisionVariable>;

So this is a definite improvement to the "Functions" summary table, but now at the function detail page http://127.0.0.1:8000/doxygen_cxx/group__solver__evaluators.html#ga70dab8652a66b1411ea56edef4b0b995, we end up with a too-wide table such that the longform description ends up with an annoying scrollbar.

I pushed a CSS fix for this to your branch (be sure to pull it locally before you make any further changes).


solvers/mathematical_program.h line 3158 at r1 (raw file):

   * @throws std::exception if the pre condition is not satisfied.
   */

nit Remove newly-added spurious blank line between comment and function.


solvers/mathematical_program_result.h line 190 at r1 (raw file):

  [[nodiscard]] typename std::enable_if_t<
      std::is_same_v<typename Derived::Scalar, symbolic::Variable>,
      MatrixLikewise<double, Derived>>

BTW Several of the member functions on MathematicalProgramResult have the same "enable_if makes the table layout unreadable" problem, e.g., GetSolution here.

Shall we also try to fix those in this PR?

Copy link
Copy Markdown
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

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

@jwnimmer-tri reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: 3 unresolved discussions, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi)

@j4yyousi
Copy link
Copy Markdown
Contributor Author

Hi @jwnimmer-tri, did you get a chance to review the updates?

Copy link
Copy Markdown
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

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

Everything but the CSS looked fine. I got stuck trying to figure out how to review the CSS. See new discussion thread, below.

@jwnimmer-tri reviewed 2 of 3 files at r3, all commit messages.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee jwnimmer-tri(platform), needs at least two assigned reviewers, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi)


doc/doxygen_cxx/doxygen_extra.css line 85 at r3 (raw file):

}

td.memItemLeft {

I am having trouble understanding the effect of this additional CSS.

Please provide me with one or sample pages (like "mathematical program class" or "solvers namespace") and explain where I should compare to see the effect (e.g., which function names or etc). I'll open the page with this css and then remove the css and look again. By comparing the two, I'll be able to understand what the CSS doing.

(In both cases, I will use the content of this PR for comparing, i.e., with the requires re-spellings already done.)

@j4yyousi
Copy link
Copy Markdown
Contributor Author

j4yyousi commented Nov 29, 2025

Hi, here are instructions on how to view the effect of the CSS in http://127.0.0.1:8000/doxygen_cxx/classdrake_1_1solvers_1_1_mathematical_program.html as an example:

  1. go to AddSosConstraint function where some of its overloads have long std::pair return types. If the middle partition is expanded enough, then your screen should look something like this:
Screenshot from 2025-11-29 18-59-36
  1. shrink the middle partition by expanding the table of contents on the left to have something like this:
Screenshot from 2025-11-29 19-00-10 With the CSS applied, you can see that the return types will have horizontal scroll bars, while the function names and parameters are fully visible.
  1. If you remove the CSS, then you should see the following:
Screenshot from 2025-11-29 19-02-10 Where the long return types push the function name and its parameters out of sight and you will have to use the table's horizontal scroll bar.

Actually you can see the effect on any page by narrowing function declarations enough.

Here's another page with long-return-type functions :
Screenshot from 2025-11-29 20-42-59

@jwnimmer-tri
Copy link
Copy Markdown
Collaborator

The only sticking point here is the CSS layout changes. Reviewing (locally testing) that part is taking some time. If you would like to land this PR sooner than later, you could revert the the CSS edit and I could land the PR as-is with just the nice API fixups. Then we could revisit the CSS layout in a second PR.

Or if you're not in a hurry, it's fine to leave it all-on-one here and I'll circle back time permitting.

@j4yyousi
Copy link
Copy Markdown
Contributor Author

No worries take your time. I'll leave the PR as is unless instructed otherwise.

@tyler-yankee tyler-yankee self-assigned this Jan 7, 2026
Copy link
Copy Markdown
Contributor

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

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

@tyler-yankee reviewed 5 files and all commit messages, and made 2 comments.
Reviewable status: 2 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tyler-yankee, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).


doc/doxygen_cxx/doxygen_extra.css line 85 at r3 (raw file):

Previously, jwnimmer-tri (Jeremy Nimmer) wrote…

I am having trouble understanding the effect of this additional CSS.

Please provide me with one or sample pages (like "mathematical program class" or "solvers namespace") and explain where I should compare to see the effect (e.g., which function names or etc). I'll open the page with this css and then remove the css and look again. By comparing the two, I'll be able to understand what the CSS doing.

(In both cases, I will use the content of this PR for comparing, i.e., with the requires re-spellings already done.)

See my top-level thread for an example of what this PR does on a page unrelated to the solvers changes.


a discussion (no related file):
BTW, one could make a similar argument regarding readability for the drake Namespace Reference page (https://drake.mit.edu/doxygen_cxx/namespacedrake.html). Screenshot from a 27" wide monitor on the currently rendered site from master as of writing:

image copy 1.png

I understand this page has a lot more "stuff" to account for than drake::solvers::MathematicalProgram, but point still stands.

With this PR, you get something like:

image.png

I also noticed that the navigation on the right was gone by default with the PR but present by default on master; I had to grab and widen/open it with the mouse. I imagine that menu can be useful for some longer pages and some might miss that it still exists if it's hidden.

Note that on a smaller screen (e.g. my laptop instead of wide monitor) this creates some scroll bars for longer return types, a la:

image copy 2.png

I think this is intended based on the commit message? But wanted to point it out for review's sake.

My 2c: the solvers changes and the CSS changes are somewhat distinct, and could be landed as separate PRs. At the very least IMO the PR title+description (resulting commit message on master) should be pivoted to be more of a documentation change, since it's affecting the styling of the entire website.

@j4yyousi
Copy link
Copy Markdown
Contributor Author

j4yyousi commented Jan 7, 2026

Hi Tyler, opening https://drake.mit.edu/doxygen_cxx/namespacedrake.html using chrome on master shows the page without the navigation bar on the right for me:
image.png

I had to drag the bar manually to show it:
image copy 1.png

When I open the link using Firefox, the right bar is expanded by default:
image copy 2.png

Looks like this issue is browser dependent, and independent of the PR since it persists on master. Do you mind confirming on this part?

this creates some scroll bars for longer return types, a la: ... I think this is intended based on the commit message?

Yes correct. Having the horizontal scroll bar in the left column makes the right column have fixed size. Which makes the table accommodate resizing.

Copy link
Copy Markdown
Contributor

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

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

@tyler-yankee made 1 comment.
Reviewable status: 2 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tyler-yankee, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).


a discussion (no related file):

Looks like this issue is browser dependent, and independent of the PR since it persists on master.

Interesting. I typically use Chrome, but even incognito Chrome or Firefox I still always get the right bar. Perhaps it's something cached in the browser. I think I'm satisfied with that as long it's observably unaffected by this PR somewhere.

Having the horizontal scroll bar in the left column makes the right column have fixed size. Which makes the table accommodate resizing.

Thanks for clarifying!

Copy link
Copy Markdown
Contributor

@tom-osika tom-osika left a comment

Choose a reason for hiding this comment

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

@tom-osika made 2 comments.
Reviewable status: 3 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tyler-yankee, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).


a discussion (no related file):

Previously, tyler-yankee (Tyler Yankee) wrote…

Looks like this issue is browser dependent, and independent of the PR since it persists on master.

Interesting. I typically use Chrome, but even incognito Chrome or Firefox I still always get the right bar. Perhaps it's something cached in the browser. I think I'm satisfied with that as long it's observably unaffected by this PR somewhere.

Having the horizontal scroll bar in the left column makes the right column have fixed size. Which makes the table accommodate resizing.

Thanks for clarifying!

Adding another piece to the puzzle: I tried this out myself in 3 incognito tabs (chrome, Firefox, and Microsoft edge) and between this branch and master, I always got the right bar. If I didn't open in an incognito tab, the behavior was much less consistent (sometimes it would be there on one browser but not the other).


a discussion (no related file):
On firefox when viewed from mobile, there's some squashing of letters for documentation entries that otherwise would have a scroll bar. See below:

firefox_overlap.png

Note that this also happens when viewed in landscape.

Otherwise, the scrollbar works on mobile. Here's a demo in landscape and portrait on chrome (edge looked basically the same)
chrome_landscape_demo.webm

chrome_portrait_demo.webm

Copy link
Copy Markdown
Contributor

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

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

@tyler-yankee made 1 comment and resolved 1 discussion.
Reviewable status: 2 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tyler-yankee,tom-osika, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).


a discussion (no related file):

Previously, tom-osika (Tom Osika) wrote…

Adding another piece to the puzzle: I tried this out myself in 3 incognito tabs (chrome, Firefox, and Microsoft edge) and between this branch and master, I always got the right bar. If I didn't open in an incognito tab, the behavior was much less consistent (sometimes it would be there on one browser but not the other).

Thanks for checking this, Tom! Sounds like the bar is unaffected by the PR then

Comment thread doc/doxygen_cxx/doxygen_extra.css Outdated
Copy link
Copy Markdown
Contributor Author

@j4yyousi j4yyousi left a comment

Choose a reason for hiding this comment

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

@j4yyousi made 2 comments.
Reviewable status: 3 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tyler-yankee,tom-osika, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).


a discussion (no related file):

Previously, tom-osika (Tom Osika) wrote…

On firefox when viewed from mobile, there's some squashing of letters for documentation entries that otherwise would have a scroll bar. See below:

firefox_overlap.png

Note that this also happens when viewed in landscape.

Otherwise, the scrollbar works on mobile. Here's a demo in landscape and portrait on chrome (edge looked basically the same)
chrome_landscape_demo.webm

chrome_portrait_demo.webm

Thanks for testing Tom!

Comment thread doc/doxygen_cxx/doxygen_extra.css Outdated
Copy link
Copy Markdown
Contributor

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

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

@tyler-yankee reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: 3 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tyler-yankee,tom-osika, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).


a discussion (no related file):

Previously, j4yyousi (Khaled Al-jayyousi) wrote…

Thanks for testing Tom!

@j4yyousi is there anything that can be done to mitigate this? The method in the middle there might as well be unreadable/useless on mobile with the changes.

(To clarify, while I'm generally favor of the styling changes for readability throughout the rest of the site, this effect is a real booger.)

Copy link
Copy Markdown
Member

@williamjallen williamjallen left a comment

Choose a reason for hiding this comment

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

The CSS itself looks reasonable to me, but I'll defer to others for comments on whether the UI looks the way it should.

@williamjallen reviewed 5 files and all commit messages, and made 1 comment.
Reviewable status: 3 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tyler-yankee,tom-osika, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).

Copy link
Copy Markdown
Member

@williamjallen williamjallen left a comment

Choose a reason for hiding this comment

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

@williamjallen resolved 1 discussion.
Reviewable status: 2 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tyler-yankee,tom-osika, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).

Copy link
Copy Markdown
Contributor

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

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

I've pushed a merge commit to bring the branch "up to speed" (upgrade to Bazel 9 and some arch-related rcfile changes have since landed on master, which makes the old branch slightly annoying to work off of), and a small commit to adjust the height/thickness of the scrollbar. It makes it more consistent with the thickness of other scrollbars on the page, and makes it generally look less awkward compared with the height of the textbox for the method.

@tyler-yankee made 1 comment.
Reviewable status: 2 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tyler-yankee,tom-osika, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).

Copy link
Copy Markdown
Contributor

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

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

:lgtm: pending the other open thread. I'd also ideally like to see the PR description (or really just the extended commit message when merged), and possibly the title, modified to indicate the scope of the CSS changes. Thanks for your effort on this, Khaled!

@tyler-yankee made 1 comment.
Reviewable status: 2 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tom-osika, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).

@j4yyousi
Copy link
Copy Markdown
Contributor Author

Previously, tyler-yankee (Tyler Yankee) wrote…

@j4yyousi is there anything that can be done to mitigate this? The method in the middle there might as well be unreadable/useless on mobile with the changes.

(To clarify, while I'm generally favor of the styling changes for readability throughout the rest of the site, this effect is a real booger.)

I'll investigate further and get back hopefully by the weekend.

@j4yyousi
Copy link
Copy Markdown
Contributor Author

Previously, j4yyousi (Khaled Al-jayyousi) wrote…

I'll investigate further and get back hopefully by the weekend.

I have tested the CSS on my Iphone and got a different result for Firefox with no overlapping text, but the horizontal scroll bar has a white color which is difficult to see:
iphone_firefox_scrollbar_8003.mov

And here is the same page for chrome:
iphone_chrome_scrollbar_8003.mov

Since the horizontal scrollbar is only visible while scrolling on mobile, the UI is less intuitive than on desktop. Also, the added CSS is interpreted differently by the browsers leading to inconsistent views. Thus, I'll revert my CSS changes. On Iphone, the reverted page will look like this on Firefox and Chrome:
iphone_firefox_noscrollbar_8001.mov

Copy link
Copy Markdown
Contributor

@tyler-yankee tyler-yankee left a comment

Choose a reason for hiding this comment

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

@tyler-yankee made 1 comment.
Reviewable status: 2 unresolved discussions, LGTM missing from assignees jwnimmer-tri(platform),tom-osika, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @j4yyousi).


a discussion (no related file):

Since the horizontal scrollbar is only visible while scrolling on mobile, the UI is less intuitive than on desktop.

https://stackoverflow.com/questions/68988224/scrollbar-css-not-showing-on-iphone-chrome-and-safari may be relevant here? This may just be a Safari browser-thing, I'm not sure there's much our project styling can control.

Personally, I'd still be in favor of keeping the CSS changes, but author's discretion / open to other reviewers' thoughts.

@j4yyousi
Copy link
Copy Markdown
Contributor Author

Yeah it doesn't look like it provides a solution for all browsers. Regarding Tom's overlapping text issue:
image.png
It is the result of having a fixed table layout table-layout: fixed; in doxygen_extra.css. The fixed table layout is necessary to show the horizontal scroll bars.

My understanding is that new html elements cannot be added in Doxygen's generated files. Otherwise, adding a <div> inside table cell elements <td> might be sufficient to providing a consistent view across browsers.

Personally, I'd still be in favor of keeping the CSS changes...

If the side effects on mobile browsers can be ignored, then sure we can proceed with the CSS changes. Otherwise, the shortening of function signatures should be sufficient for now. What do you think?

Copy link
Copy Markdown
Collaborator

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

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

:lgtm:

@jwnimmer-tri reviewed 3 files and all commit messages, made 2 comments, resolved 2 discussions, and dismissed @tom-osika and @tyler-yankee from a discussion.
Reviewable status: LGTM missing from assignee tom-osika, commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on j4yyousi).


a discussion (no related file):

Previously, j4yyousi (Khaled Al-jayyousi) wrote…

Yeah it doesn't look like it provides a solution for all browsers. Regarding Tom's overlapping text issue:
image.png
It is the result of having a fixed table layout table-layout: fixed; in doxygen_extra.css. The fixed table layout is necessary to show the horizontal scroll bars.

My understanding is that new html elements cannot be added in Doxygen's generated files. Otherwise, adding a <div> inside table cell elements <td> might be sufficient to providing a consistent view across browsers.

Personally, I'd still be in favor of keeping the CSS changes...

If the side effects on mobile browsers can be ignored, then sure we can proceed with the CSS changes. Otherwise, the shortening of function signatures should be sufficient for now. What do you think?

The CSS changes have been reverted, so I'll close this thread.

@jwnimmer-tri jwnimmer-tri added the status: squashing now https://drake.mit.edu/reviewable.html#curated-commits label Feb 23, 2026
@jwnimmer-tri jwnimmer-tri merged commit 464856d into RobotLocomotion:master Feb 23, 2026
8 of 9 checks passed
j4yyousi added a commit to j4yyousi/drake that referenced this pull request Mar 2, 2026
Shorten lengthy return types to fix Doxygen's pages by:
1) Migrating some declarations from `std::enable_if` to `requires`
2) Using trialing return types

Also in the CSS, allow line wrapping in trailing return types.

Co-authored-by: Jeremy Nimmer <jeremy.nimmer@tri.global>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes: none This pull request should not be mentioned in the release notes status: squashing now https://drake.mit.edu/reviewable.html#curated-commits

Development

Successfully merging this pull request may close these issues.

doxygen website doesn't scroll horizontally enough to see workspace methods Doxygen for MathematicalProgram is unreadable

5 participants