File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 1
1
use anyhow:: { Result , anyhow} ;
2
- use crates_io_docs_rs:: { DocsRsClient , RealDocsRsClient } ;
2
+ use crates_io_docs_rs:: { DEFAULT_BASE_URL , DocsRsClient , RealDocsRsClient } ;
3
3
use std:: env;
4
4
use url:: Url ;
5
5
@@ -11,7 +11,7 @@ async fn main() -> Result<()> {
11
11
. nth ( 1 )
12
12
. ok_or_else ( || anyhow ! ( "Missing access token" ) ) ?;
13
13
14
- let docs_rs = RealDocsRsClient :: new ( Url :: parse ( "https://docs.rs" ) ?, access_token) ;
14
+ let docs_rs = RealDocsRsClient :: new ( Url :: parse ( DEFAULT_BASE_URL ) ?, access_token) ;
15
15
16
16
docs_rs. rebuild_docs ( "empty-library" , "1.0.0" ) . await ?;
17
17
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ use serde::Deserialize;
7
7
use tracing:: warn;
8
8
use url:: Url ;
9
9
10
+ pub const DEFAULT_BASE_URL : & str = "https://docs.rs" ;
11
+
10
12
#[ derive( Debug , thiserror:: Error ) ]
11
13
pub enum DocsRsError {
12
14
/// The rebuild couldn't be triggered.
@@ -57,7 +59,7 @@ impl RealDocsRsClient {
57
59
pub fn from_environment ( ) -> Option < Self > {
58
60
let base_url: Url = match var_parsed ( "DOCS_RS_BASE_URL" ) {
59
61
Ok ( Some ( url) ) => url,
60
- Ok ( None ) => Url :: parse ( "https://docs.rs" ) . unwrap ( ) ,
62
+ Ok ( None ) => Url :: parse ( DEFAULT_BASE_URL ) . unwrap ( ) ,
61
63
Err ( err) => {
62
64
warn ! ( ?err, "Failed to parse DOCS_RS_BASE_URL" ) ;
63
65
return None ;
You can’t perform that action at this time.
0 commit comments