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

Enable the use of alternate fonts in cargo doc. #11530

Closed
arj0019 opened this issue Jan 3, 2023 · 6 comments
Closed

Enable the use of alternate fonts in cargo doc. #11530

arj0019 opened this issue Jan 3, 2023 · 6 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@arj0019
Copy link

arj0019 commented Jan 3, 2023

Problem

I would like to utilize alternate fonts with cargo doc. I specifically seek the ability to utilize monospace fonts.

Proposed Solution

Allow the user to configure cargo doc via the command line and/or configuration file.

Notes

No response

@arj0019 arj0019 added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Jan 3, 2023
@weihanglo
Copy link
Member

rustdoc provides a couple of flags letting you customize CSS:

You can combine them with Cargo's config value build.rustdocflags or command cargo rustdoc to get what you want.

@weihanglo
Copy link
Member

Cargo does promote flags from rustc/rustdoc to become first-class flags of Cargo itself, such as cargo doc --document-private-items (#1520). However, for this case I feel like it is not that frequent to tweak style via command line. It should be more common to set up a configuration for styling once and for all.

As a result, I am going to close this given the alternatives are obvious. Thank you!

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2023
@arj0019
Copy link
Author

arj0019 commented Jan 19, 2023

I am able to implement the cargo config file, but it does not recognize the --markdown-css flag and there is no example of interfacing with the rustdoc CSS.

PS C:\Users\johnsoar\Documents\Personal\GITHUB\charts> cargo doc
 Documenting charts v0.1.0 (C:\Users\johnsoar\Documents\Personal\GITHUB\charts)
error: Unrecognized option: 'markdown-css docstyle.css'

error: could not document `charts`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2021 --crate-type lib --crate-name charts src\lib.rs -o C:\Users\johnsoar\Documents\Personal\GITHUB\charts\target\doc --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat -C metadata=8b232a5edf7611e6 -L dependency=C:\Users\johnsoar\Documents\Personal\GITHU
B\charts\target\debug\deps "--markdown-css docstyle.css" --crate-version 0.1.0` (exit code: 1)

@weihanglo
Copy link
Member

Your arguments are merged into one "--markdown-css docstyle.css". If you're using Cargo configuration, try using array, like rustdocflags = ["--markdown-css", "docstyle.css"].

@arj0019
Copy link
Author

arj0019 commented Jan 19, 2023

Is there documentation of how to implement custom CSS for rustdoc? Where is the default CSS located?

@weihanglo
Copy link
Member

Links above #11530 (comment) are probably enough to play with.

There is also an old article from an official rustdoc team member talking about unstable --extend-css stuff (now stabilized).

I guess the default CSS is embedded in the rustdoc source code and generated on-the-fly, though I am not familiar with rustdoc internals.

Hope these help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

2 participants