Skip to content

Commit 53084eb

Browse files
committed
Get intralink information from rustdoc.
1 parent 8167f99 commit 53084eb

File tree

67 files changed

+1394
-1174
lines changed

Some content is hidden

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

67 files changed

+1394
-1174
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,17 @@ jobs:
2020
os: [ubuntu-latest, macos-latest, windows-latest]
2121

2222
steps:
23-
- name: Install rust
23+
- name: Install rust (stable)
2424
uses: dtolnay/rust-toolchain@stable
25-
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
25+
26+
# We need to install rust nightly to run the integration tests: nightly is needed to get the rustdoc information
27+
# for intralinks. This will not be needed once that feature stabilizes
28+
# (https://github.com/rust-lang/rust/issues/76578).
29+
- name: Install rust (nightly)
30+
uses: dtolnay/rust-toolchain@nightly
31+
32+
- name: Use stable rust for the build
33+
run: rustup default stable
2934

3035
- name: Install cargo plugins
3136
run: |

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ git2 = { version = "0.19.0", default-features = false }
3939
indoc = "2.0.5"
4040
itertools = "0.13.0"
4141
pulldown-cmark = "0.12.2"
42+
rustdoc-json = "0.9.3"
43+
rustdoc-types = "0.33.0"
44+
serde_json = "1.0.134"
4245
syn = { version = "2.0.91", features = ["full", "extra-traits"] }
4346
termcolor = "1.4.1"
4447
thiserror = "2.0.9"

src/console.rs

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

1212
pub use termcolor::Color;
1313

14-
fn is_stderr_terminal() -> bool {
14+
pub fn is_stderr_terminal() -> bool {
1515
std::io::stderr().is_terminal()
1616
}
1717

src/lib.rs

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

50+
#[derive(Debug)]
51+
pub enum PackageTarget {
52+
Bin { crate_name: String },
53+
Lib,
54+
}
55+
5056
#[derive(PartialEq, Eq, Debug)]
5157
pub struct Project {
5258
package_name: String,
59+
manifest_path: PathBuf,
5360
readme_path: Option<PathBuf>,
5461
lib_path: Option<PathBuf>,
5562
bin_path: HashMap<String, PathBuf>,
@@ -110,16 +117,16 @@ impl Project {
110117
let bin_packages =
111118
package.targets.iter().filter(|target| target.kind.contains(&TargetKind::Bin));
112119

113-
let directory = package
114-
.manifest_path
115-
.clone()
116-
.into_std_path_buf()
120+
let manifest_path = package.manifest_path.clone().into_std_path_buf();
121+
122+
let directory = manifest_path
117123
.parent()
118124
.expect("error getting the parent path of the manifest file")
119125
.to_path_buf();
120126

121127
Project {
122128
package_name: package.name.clone(),
129+
manifest_path,
123130
readme_path: package.readme.as_ref().map(|p| p.clone().into_std_path_buf()),
124131
lib_path: lib_package.map(|t| t.src_path.clone().into_std_path_buf()),
125132
bin_path: bin_packages
@@ -134,6 +141,14 @@ impl Project {
134141
self.lib_path.as_ref().filter(|p| p.is_file()).map(PathBuf::as_path)
135142
}
136143

144+
#[must_use]
145+
pub fn get_bin_default_crate_name(&self) -> Option<&str> {
146+
match self.bin_path.len() {
147+
1 => self.bin_path.keys().next().map(String::as_str),
148+
_ => None,
149+
}
150+
}
151+
137152
#[must_use]
138153
pub fn get_bin_default_entryfile_path(&self) -> Option<&Path> {
139154
match self.bin_path.len() {
@@ -164,15 +179,11 @@ impl Project {
164179
pub fn get_package_name(&self) -> &str {
165180
&self.package_name
166181
}
167-
}
168182

169-
fn project_package_name(manifest_path: impl AsRef<Path>) -> Option<String> {
170-
let str: String = std::fs::read_to_string(&manifest_path).ok()?;
171-
let toml: toml::Value = toml::from_str(&str).ok()?;
172-
let package_name =
173-
toml.get("package").and_then(|v| v.get("name")).and_then(toml::Value::as_str)?;
174-
175-
Some(package_name.to_owned())
183+
#[must_use]
184+
pub fn get_manifest_path(&self) -> &PathBuf {
185+
&self.manifest_path
186+
}
176187
}
177188

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

0 commit comments

Comments
 (0)