Hi
I've not worked my way through enough of the devtools code to properly understand the consequences of this idea, hence I am posing it as a question, not a suggestion.
I have come across a problem when I have an @include in a package hat has not yet been processed by using devtools::document(), and hence the automatically generated Collate: field in my DESCRIPTION file does not yet know about the @include tag. If the default sort order of the filenames involved in the as yet unprocessed @include tag puts them in the wrong order, devtools::load_all() fails, somewhere around the load_code line in the following section of code
insert_imports_shims(pkg)
out$data <- load_data(pkg)
out$code <- load_code(pkg)
register_s3(pkg)
Because load_all() fails, the later steps in document() do not get run, and the Collate field in the DESCRPTION file does not get updated (unless by luck or trickery I comment out enough of the package code to get a Collate field generated that does what is needed, and then try again).
From my reading of documentation and perusal of devtools and roxygen2 code I suspect that a call to roxygen2:::update_collate would remedy this. That would probably be mean adding a call something like
with_envvar(r_env_vars(), roxygen2::roxygenise(pkg$path, roclets = 'collate', load_code = ns_env))
in the line before
out$code <- load-code(pkg)
I haven't understood enough yet to be sure I've got the syntax of the roxygen2 call correct, nor that the arguments I have put in (which I have merely copied from later in the code of devtools::document) have actually been created or initialised at that stage of the load_all code, so it would need someone who knows more about how devtools works to vet / correct my suggestion.
Hoping this is useful
Regards
Geoff
PS I'm learning heaps by looking through the devtools code - many thanks to everyone who has put it together.