-
Notifications
You must be signed in to change notification settings - Fork 335
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
Allow building all docs with a local repo #659
Changes from all commits
72d82a2
ee327bf
e26c457
fdc99b1
b1acdaa
26a0d97
78af0ff
61718ef
84736eb
afc156e
df51f1d
71a0e02
412d80a
4cec727
e22093b
36e07c5
669f659
11b221a
cca7455
6e35214
b27729d
e8ed6b4
68a4220
204bbaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ BEGIN | |
|
||
GetOptions( | ||
$Opts, # | ||
'all', 'push', 'target_repo=s', 'reference=s', 'rebuild', 'no_fetch', # | ||
'all', 'push', 'target_repo=s', 'reference=s', 'rebuild', 'keep_hash', 'sub_dir=s@', | ||
'single', 'pdf', 'doc=s', 'out=s', 'toc', 'chunk=i', 'suppress_migration_warnings', | ||
'open', 'skiplinkcheck', 'linkcheckonly', 'staging', 'procs=i', 'user=s', 'lang=s', | ||
'lenient', 'verbose', 'reload_template', 'resource=s@', 'asciidoctor', 'in_standard_docker', | ||
|
@@ -464,7 +464,11 @@ sub init_repos { | |
user => $Opts->{user}, | ||
url => $Opts->{target_repo}, | ||
reference => $reference_dir, | ||
# intentionally not passing the tracker because we don't want to use it | ||
# We can't keep the hash of the target repo because it is what stores | ||
# the hashes in the first place! | ||
keep_hash => 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it's worth a review comment, is it worth a code comment? |
||
# Intentionally not passing the tracker because we need to build the | ||
# tracker from information in this repo. | ||
); | ||
delete $child_dirs{ $target_repo->git_dir->absolute }; | ||
my $target_repo_checkout = "$temp_dir/target_repo"; | ||
|
@@ -498,6 +502,7 @@ sub init_repos { | |
user => $Opts->{user}, | ||
url => $url, | ||
reference => $reference_dir, | ||
keep_hash => $Opts->{keep_hash}, | ||
); | ||
delete $child_dirs{ $repo->git_dir->absolute }; | ||
|
||
|
@@ -507,7 +512,7 @@ sub init_repos { | |
else { | ||
$pm->start($name) and next; | ||
eval { | ||
$repo->update_from_remote() unless $Opts->{no_fetch}; | ||
$repo->update_from_remote(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I drop this feature because |
||
1; | ||
} or do { | ||
# If creds are invalid, explicitly reject them to try to clear the cache | ||
|
@@ -522,6 +527,16 @@ sub init_repos { | |
} | ||
$pm->wait_all_children; | ||
|
||
# Parse the --sub_dir options and attach the to the repo | ||
my %sub_dirs = (); | ||
foreach (@{ $Opts->{sub_dir} }) { | ||
die "invalid --sub_dir $_" | ||
unless /(?<repo>[^:]+):(?<branch>[^:]+):(?<dir>.+)/; | ||
my $dir = dir($+{dir})->absolute; | ||
die "--sub_dir $dir doesn't exist" unless -e $dir; | ||
ES::Repo->get_repo($+{repo})->add_sub_dir($+{branch}, $dir); | ||
} | ||
|
||
for ( keys %child_dirs ) { | ||
my $dir = dir($_); | ||
next unless -d $dir; | ||
|
@@ -682,7 +697,8 @@ sub check_args { | |
die('--user not compatible with --doc') if $Opts->{user}; | ||
die('--reference not compatible with --doc') if $Opts->{reference}; | ||
die('--rebuild not compatible with --doc') if $Opts->{rebuild}; | ||
die('--no_fetch not compatible with --doc') if $Opts->{no_fetch}; | ||
die('--keep_hash not compatible with --doc') if $Opts->{keep_hash}; | ||
die('--sub_dir not compatible with --doc') if $Opts->{sub_dir}; | ||
die('--skiplinkcheck not compatible with --doc') if $Opts->{skiplinkcheck}; | ||
die('--linkcheckonly not compatible with --doc') if $Opts->{linkcheckonly}; | ||
} else { | ||
|
@@ -703,9 +719,10 @@ sub pick_conf { | |
#=================================== | ||
return 'conf.yaml' unless $Opts->{conf}; | ||
|
||
my $conf = dir($Old_Pwd)->file($Opts->{conf}); | ||
my $conf = file($Opts->{conf}); | ||
$conf = dir($Old_Pwd)->file($Opts->{conf}) if $conf->is_relative; | ||
return $conf if -e $conf; | ||
die $Opts->{conf} . " doesn't exist"; | ||
die "$conf doesn't exist"; | ||
} | ||
|
||
#=================================== | ||
|
@@ -793,7 +810,9 @@ sub usage { | |
--skiplinkcheck Omit the step that checks for broken links | ||
--linkcheckonly Skips the documentation builds. Checks links only. | ||
--rebuild Rebuild all branches of every book regardless of what has changed | ||
--no_fetch Skip fetching updates from source repos | ||
--keep_hash Build docs from the same commit hash as last time | ||
--sub_dir Use a directory as a branch of some repo | ||
(eg --sub_dir elasticsearch:master:~/Code/elasticsearch) | ||
ninaspitfire marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
General Opts: | ||
--staging Use the template from the staging website | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
= Title | ||
|
||
== Chapter | ||
|
||
I include simple between here | ||
|
||
include::../../source2/index.asciidoc[] | ||
|
||
and here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you add features, all the manual parsing of
argv
is going to cost you more and more.argparse
isn't great, but is there any value in considering it over full DIY?(Normally, I would suggest Click, but I know you can't do packages.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've considered it on and off for a while. I think the value that DIY gets me is being able to pass through arguments that I don't know about. I only rewrite the arguments that have anything to do with paths. The cost of DIY is that I need this everywhere. At this point I think it is net simpler, but I'd be receptive to any argument to the contrary. Like, I wonder if it'd be helpful to force me to list all of the supported arguments in the python file because we plan to drop the perl file one day.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. I trust your judgement.