Skip to content

Commit

Permalink
rustdoc changes (source links and feature labels) (#38)
Browse files Browse the repository at this point in the history
There are two proposed changes in this pull request:
- Make the docs generated on docs.rs use
`--generate-link-to-definitions`, so the source is a little more
convenient to brows on docs.rs. (See example
[here](https://docs.rs/ump-ng-server/0.3.0/src/ump_ng_server/lib.rs.html#54-74))
- Enable all features when generating docs on docs.rs and instead use
feature labels in order to mark what features are required for
individual items.

To generate docs with feature labels locally use:
```
$ RUSTFLAGS="--cfg docsrs" RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features
```

(`cargo doc` still works as usual).
  • Loading branch information
avastmick authored May 28, 2024
2 parents 2132249 + fdb903d commit cae1fa2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ reqwest-streams = { version = "0.5", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0" }
tokio = { version = "1.35", features = ["full"] }

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod v1;
6 changes: 6 additions & 0 deletions src/v1/gemini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub enum Model {
#[default]
GeminiPro,
#[cfg(feature = "beta")]
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
Gemini1_5Pro,
GeminiProVision,
// TODO Embedding001
Expand Down Expand Up @@ -210,6 +211,7 @@ pub mod request {
pub generation_config: Option<GenerationConfig>,

#[cfg(feature = "beta")]
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default, rename = "system_instruction")]
pub system_instruction: Option<SystemInstructionContent>,
Expand All @@ -232,6 +234,7 @@ pub mod request {
}

#[cfg(feature = "beta")]
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
pub fn set_system_instruction(&mut self, instruction: SystemInstructionContent) {
self.system_instruction = Some(instruction);
}
Expand Down Expand Up @@ -314,17 +317,20 @@ pub mod request {
pub stop_sequences: Option<Vec<String>>,

#[cfg(feature = "beta")]
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
pub response_mime_type: Option<String>,
}

#[cfg(feature = "beta")]
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct SystemInstructionContent {
#[serde(default)]
pub parts: Vec<SystemInstructionPart>,
}

#[cfg(feature = "beta")]
#[cfg_attr(docsrs, doc(cfg(feature = "beta")))]
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct SystemInstructionPart {
Expand Down

0 comments on commit cae1fa2

Please sign in to comment.