Skip to content

Commit 0b01e04

Browse files
authored
Merge pull request RustPython#3638 from youknowone/derive
rustpython-doc as external module
2 parents c44843f + e609aca commit 0b01e04

File tree

7 files changed

+17
-2247
lines changed

7 files changed

+17
-2247
lines changed

Cargo.lock

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

derive/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ once_cell = "1.10.0"
2222
textwrap = { version = "0.15.0", default-features = false }
2323
indexmap = "1.8.1"
2424
itertools = "0.10.3"
25+
rustpython-doc = { git = "https://github.com/RustPython/__doc__", branch = "main" }

derive/docs.rsinc

Lines changed: 0 additions & 2213 deletions
This file was deleted.

derive/src/doc.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

derive/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ mod error;
1313
mod util;
1414

1515
mod compile_bytecode;
16-
mod doc;
1716
mod from_args;
1817
mod pyclass;
1918
mod pymodule;
@@ -23,6 +22,7 @@ mod pystructseq;
2322
use error::{extract_spans, Diagnostic};
2423
use proc_macro2::TokenStream;
2524
use quote::ToTokens;
25+
use rustpython_doc as doc;
2626
use syn::{parse_macro_input, AttributeArgs, DeriveInput, Item};
2727

2828
fn result_to_tokens(result: Result<TokenStream, impl Into<Diagnostic>>) -> proc_macro::TokenStream {

derive/src/pyclass.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@ fn generate_class_def(
191191
) -> Result<TokenStream> {
192192
let doc = attrs.doc().or_else(|| {
193193
let module_name = module_name.unwrap_or("builtins");
194-
crate::doc::try_module_item(module_name, name)
194+
crate::doc::Database::shared()
195+
.try_module_item(module_name, name)
195196
.ok()
196197
.flatten()
197198
.map(str::to_owned)

derive/src/pymodule.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ pub fn impl_pymodule(attr: AttributeArgs, module_item: Item) -> Result<TokenStre
8989
let module_name = context.name.as_str();
9090
let module_extend_items = context.module_extend_items.validate()?;
9191
let doc = doc.or_else(|| {
92-
crate::doc::try_read(module_name)
92+
crate::doc::Database::shared()
93+
.try_path(module_name)
9394
.ok()
9495
.flatten()
9596
.map(str::to_owned)
@@ -320,7 +321,8 @@ impl ModuleItem for FunctionItem {
320321
let (tokens, py_names) = {
321322
let module = args.module_name();
322323
let doc = args.attrs.doc().or_else(|| {
323-
crate::doc::try_module_item(module, &py_name)
324+
crate::doc::Database::shared()
325+
.try_module_item(module, &py_name)
324326
.ok() // TODO: doc must exist at least one of code or CPython
325327
.flatten()
326328
.map(str::to_owned)

0 commit comments

Comments
 (0)