Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Switch to doc cfg instead of feature dox" #1010

Merged
merged 1 commit into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/codegen/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ pub fn uses(w: &mut dyn Write, env: &Env, imports: &Imports) -> Result<()> {
if !scope.constraints.is_empty() {
writeln!(
w,
"#[cfg(any({}, all(not(doctest), doc)))]",
"#[cfg(any({},feature = \"dox\"))]",
scope.constraints.join(", ")
)?;
writeln!(
w,
"#[cfg_attr(all(not(doctest), doc), doc(cfg({})))]",
"#[cfg_attr(feature = \"dox\", doc(cfg({})))]",
scope.constraints.join(", ")
)?;
}
Expand Down Expand Up @@ -558,7 +558,7 @@ pub fn not_version_condition_no_dox(
if let Some(v) = version {
let comment = if commented { "//" } else { "" };
let s = format!(
"{}{}#[cfg(not(any({}, all(not(doctest), doc))))]",
"{}{}#[cfg(not(any({}, feature = \"dox\")))]",
tabs(indent),
comment,
v.to_cfg()
Expand Down Expand Up @@ -590,7 +590,7 @@ pub fn cfg_condition_string_no_doc(
Some(v) => {
let comment = if commented { "//" } else { "" };
Some(format!(
"{0}{1}#[cfg(any({2}, all(not(doctest), doc)))]",
"{0}{1}#[cfg(any({2}, feature = \"dox\"))]",
tabs(indent),
comment,
v
Expand All @@ -609,8 +609,8 @@ pub fn cfg_condition_string(
Some(v) => {
let comment = if commented { "//" } else { "" };
Some(format!(
"{0}{1}#[cfg(any({2}, all(not(doctest), doc)))]\n\
{0}{1}#[cfg_attr(all(not(doctest), doc), doc(cfg({2})))]",
"{0}{1}#[cfg(any({2}, feature = \"dox\"))]\n\
{0}{1}#[cfg_attr(feature = \"dox\", doc(cfg({2})))]",
tabs(indent),
comment,
v
Expand Down
6 changes: 3 additions & 3 deletions src/codegen/sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn generate_build_script(w: &mut dyn Write, env: &Env, split_build_rs: bool) ->
writeln!(
w,
"{}",
r##"#[cfg(any(not(doc), doctest))]
r##"#[cfg(not(feature = "dox"))]
use std::process;"##
)?;

Expand All @@ -50,10 +50,10 @@ use std::process;"##
w,
"{}",
r##"
#[cfg(all(not(doctest), doc))]
#[cfg(feature = "dox")]
fn main() {} // prevent linking libraries to avoid documentation failure

#[cfg(any(not(doc), doctest))]
#[cfg(not(feature = "dox"))]
fn main() {
if let Err(s) = system_deps::Config::new().probe() {
let _ = eprintln!("{}", s);
Expand Down
4 changes: 3 additions & 1 deletion src/codegen/sys/cargo_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ fn fill_in(root: &mut Table, env: &Env) {
features.insert(version.to_feature(), Value::Array(prev_array));
Some(version)
});
features.insert("dox".to_string(), Value::Array(Vec::new()));
}

{
Expand Down Expand Up @@ -137,7 +138,8 @@ fn fill_in(root: &mut Table, env: &Env) {
let docs_rs_metadata = upsert_table(docs_rs_metadata, "metadata");
let docs_rs_metadata = upsert_table(docs_rs_metadata, "docs");
let docs_rs_metadata = upsert_table(docs_rs_metadata, "rs");
let docs_rs_features = env.config.docs_rs_features.clone();
let mut docs_rs_features = env.config.docs_rs_features.clone();
docs_rs_features.push("dox".to_owned());
docs_rs_metadata.insert(
"features".to_string(),
Value::Array(
Expand Down
8 changes: 2 additions & 6 deletions src/codegen/sys/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,10 @@ fn generate_object_funcs(
let name = func.c_identifier.as_ref().unwrap();
// since we work with gir-files from Linux, some function names need to be adjusted
if is_windows_utf8 {
writeln!(w, " {}#[cfg(any(windows, feature = \"dox\"))]", comment)?;
writeln!(
w,
" {}#[cfg(any(windows, all(not(doctest), doc)))]",
comment
)?;
writeln!(
w,
" {}#[cfg_attr(all(not(doctest), doc), doc(cfg(windows)))]",
" {}#[cfg_attr(feature = \"dox\", doc(cfg(windows)))]",
comment
)?;
writeln!(w, " {}pub fn {}_utf8{};", comment, name, sig)?;
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/sys/statics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn begin(w: &mut dyn Write) -> Result<()> {
"",
"#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]",
"#![allow(clippy::approx_constant, clippy::type_complexity, clippy::unreadable_literal)]",
"#![cfg_attr(all(not(doctest), doc), feature(doc_cfg))]",
"#![cfg_attr(feature = \"dox\", feature(doc_cfg))]",
"",
];

Expand Down