Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter554 committed Dec 27, 2024
1 parent 93cbda2 commit c5eea40
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,22 @@

A rust crate for parsing and analyzing the imports within a python package.

Find the docs [**here**](https://docs.rs/pyimports/0.1.0/pyimports/).
Find the docs [here](https://docs.rs/pyimports/0.1.0/pyimports/).

```rust
use anyhow::Result;

use pyimports::{testpackage,testutils::TestPackage};
use pyimports::{PackageInfo,ImportsInfo};

fn main() -> Result<()> {
let testpackage = testpackage! {
"__init__.py" => "",
"a.py" => ""
};
let package_info = PackageInfo::build(testpackage.path())?;
let imports_info = ImportsInfo::build(package_info)?;

Ok(())
}
```
25 changes: 4 additions & 21 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
//! A rust crate for parsing and analyzing the imports within a python package.
//!
//! ```rust
//! use anyhow::Result;
//!
//! use pyimports::{testpackage,testutils::TestPackage};
//! use pyimports::{PackageInfo,ImportsInfo};
//!
//! fn main() -> Result<()> {
//! let testpackage = testpackage! {
//! "__init__.py" => "",
//! "a.py" => ""
//! };
//!
//! let package_info = PackageInfo::build(testpackage.path())?;
//! let imports_info = ImportsInfo::build(package_info)?;
//!
//! Ok(())
//! }
//! ```
#![doc = include_str!("../README.md")]

mod errors;
mod imports_info;
Expand All @@ -26,7 +7,9 @@ mod utils;

// TODO: Use #[cfg(test)] here, but still need
// a way to access the testutils from doctests.
pub mod testutils;
// Related [GH issue](https://github.com/rust-lang/rust/issues/67295).
mod testutils;
pub use testutils::TestPackage;

pub use errors::Error;
pub use imports_info::{ImportMetadata, ImportsInfo, InternalImportsQueries};
Expand Down
5 changes: 0 additions & 5 deletions src/testutils.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
//! A collection of testing utilities.
//!
//! Should really be `#[cfg(test)]`, but then usage within doctests
//! doesn't seem to work. Related [GH issue](https://github.com/rust-lang/rust/issues/67295).
use anyhow::Result;
use std::collections::HashMap;
use std::fs;
Expand Down

0 comments on commit c5eea40

Please sign in to comment.