Skip to content

Commit ef97790

Browse files
committed
Get intralink information from rustdoc.
1 parent ec956cc commit ef97790

File tree

96 files changed

+1751
-1175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1751
-1175
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
- cron: '0 19 * * 3'
1010

1111
env:
12+
MIRI_TOOLCHAIN: nightly-2026-01-24
1213
CARGO_TERM_COLOR: always
1314

1415
jobs:
@@ -20,12 +21,22 @@ jobs:
2021
os: [ubuntu-latest, macos-latest, windows-latest]
2122

2223
steps:
23-
- name: Install rust
24+
- name: Install rust (stable)
2425
uses: dtolnay/rust-toolchain@stable
2526
with:
26-
# We need to install the source of the standard library for the integration tests to check that links
27-
# to the standard library are correctly generated.
28-
components: rust-src, rustfmt
27+
components: rustfmt
28+
29+
# TODO Use stable when this stabilizes (https://github.com/rust-lang/rust/issues/76578).
30+
# We need to install rust nightly to run the integration tests: nightly is needed to get the rustdoc information
31+
# for intralinks. This will not be needed once that feature stabilizes
32+
# (https://github.com/rust-lang/rust/issues/76578).
33+
- name: Install rust (nightly)
34+
uses: dtolnay/rust-toolchain@stable
35+
with:
36+
toolchain: ${{ env.INTRALINKS_TOOLCHAIN }}
37+
38+
- name: Use stable rust for the build
39+
run: rustup default stable
2940

3041
- name: Install cargo plugins
3142
run: |

Cargo.lock

Lines changed: 148 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ git2 = { version = "0.20.3", default-features = false }
3939
indoc = "2.0.7"
4040
itertools = "0.14.0"
4141
pulldown-cmark = "0.13.0"
42+
rustdoc-json = "0.9.8"
43+
rustdoc-types = "0.57.0"
44+
rustup-toolchain = "0.1.10"
45+
serde_json = "1.0.149"
4246
syn = { version = "2.0.114", features = ["full", "extra-traits"] }
4347
termcolor = "1.4.1"
4448
thiserror = "2.0.18"

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ docs-rs-base-url = "https://mydocs.rs"
203203
docs-rs-version = "1.0.0"
204204
# If this is set the intralinks will be stripping in the README file.
205205
strip-links = false
206+
207+
# Enable all features when calling rustdoc to resolve intralinks.
208+
all-features = true
209+
# Features to enable when calling rustdoc to resolve intralinks.
210+
features = ["foo", "bar"]
211+
# Disable default features when calling rustdoc to resolve intralinks.
212+
no-default-features = false
206213
```
207214

208215
These setting can be overridden with command line flags. Run `cargo rdme --help` for more

src/console.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use termcolor::{ColorSpec, StandardStream};
66

77
pub use termcolor::Color;
88

9-
fn is_stderr_terminal() -> bool {
9+
pub fn is_stderr_terminal() -> bool {
1010
std::io::stderr().is_terminal()
1111
}
1212

src/lib.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,16 @@ pub fn find_first_file_in_ancestors(dir_path: impl AsRef<Path>, filename: &str)
4040
None
4141
}
4242

43+
#[derive(Debug)]
44+
pub enum PackageTarget {
45+
Bin { crate_name: String },
46+
Lib,
47+
}
48+
4349
#[derive(PartialEq, Eq, Debug)]
4450
pub struct Project {
4551
package_name: PackageName,
52+
manifest_path: PathBuf,
4653
readme_path: Option<PathBuf>,
4754
lib_path: Option<PathBuf>,
4855
bin_path: HashMap<String, PathBuf>,
@@ -114,16 +121,16 @@ impl Project {
114121
let bin_packages =
115122
package.targets.iter().filter(|target| target.kind.contains(&TargetKind::Bin));
116123

117-
let directory = package
118-
.manifest_path
119-
.clone()
120-
.into_std_path_buf()
124+
let manifest_path = package.manifest_path.clone().into_std_path_buf();
125+
126+
let directory = manifest_path
121127
.parent()
122128
.expect("error getting the parent path of the manifest file")
123129
.to_path_buf();
124130

125131
Project {
126132
package_name: package.name.clone(),
133+
manifest_path,
127134
readme_path: package.readme.as_ref().map(|p| p.clone().into_std_path_buf()),
128135
lib_path: lib_package.map(|t| t.src_path.clone().into_std_path_buf()),
129136
bin_path: bin_packages
@@ -138,6 +145,14 @@ impl Project {
138145
self.lib_path.as_ref().filter(|p| p.is_file()).map(PathBuf::as_path)
139146
}
140147

148+
#[must_use]
149+
pub fn get_bin_default_crate_name(&self) -> Option<&str> {
150+
match self.bin_path.len() {
151+
1 => self.bin_path.keys().next().map(String::as_str),
152+
_ => None,
153+
}
154+
}
155+
141156
#[must_use]
142157
pub fn get_bin_default_entryfile_path(&self) -> Option<&Path> {
143158
match self.bin_path.len() {
@@ -168,15 +183,11 @@ impl Project {
168183
pub fn get_package_name(&self) -> &PackageName {
169184
&self.package_name
170185
}
171-
}
172186

173-
fn project_package_name(manifest_path: impl AsRef<Path>) -> Option<String> {
174-
let str: String = std::fs::read_to_string(&manifest_path).ok()?;
175-
let toml: toml::Value = toml::from_str(&str).ok()?;
176-
let package_name =
177-
toml.get("package").and_then(|v| v.get("name")).and_then(toml::Value::as_str)?;
178-
179-
Some(package_name.to_owned())
187+
#[must_use]
188+
pub fn get_manifest_path(&self) -> &PathBuf {
189+
&self.manifest_path
190+
}
180191
}
181192

182193
#[derive(Eq, PartialEq, Clone, Debug)]

0 commit comments

Comments
 (0)