Messing around with DocBox in our site which is a ...
# box-products
j
Messing around with DocBox in our site which is a mix of vanilla code and FW/1 code. To keep things simple I'm just running the commandbox-docbox CLI utility. In our project we have an "objects" directory which I'm trying to scan. About half of these extend another CFC: "base". When I run the generate command I see an error:
Copy code
Warning! The following script has errors: objects.foo
invalid component definition, can't find component [base]
One thing to note - there is an /admin/objects/base directory and an /admin/objects/base.cfc - not sure if that matters. Anything NOT extending base works and I get documentation :) I've tried doing an 'excludes=base' but no luck.
Copy code
docbox generate strategy=HTML source=/virtual/project/www/htdocs/admin/objects mapping=objects excludes=modules|base strategy-outputDir=/virtual/project/www/htdocs/admin/mydocs strategy-projectTitle='Admin Docs'
What am I missing?? 🙂
b
What am I missing??
You're missing the same CF mappings as your web server 🙂
This is a sad and annoying downside of CFML's default CF mappings which are based on your web server's web root. It makes CFC portability a bit crap
Docbox is trying to create the CFC instances inside the Lucee server that powers the CLI (by way of the
getComponentMetada()
BIF
And in that context, the CF mappings likely don't match whatever the Lucee instance in your webserver has configured
The usual fix for this, is to give the commands any CF mappings you'd like it ot create in Lucee prior to generating the docs to try and get these component paths to resolve.
This example is from the help output of the command
Copy code
docbox generate mappings:v1.models=/path/to/modules_app/v1/models mappings:v2.models=/path/to/modules_app/v2/models strategy-outputDir=/output/path strategy-projectTitle="My Docs"
Which would register
/v1/models
and
/v2/models
as CF mappings.
Keep in mind, it is possible to fubar CommandBox's core itself if you were to, say, create a
/wirebox
mapping as CFML offers no mechanism to sandbox execution unfortunatley.
j
I gotcha - so tweak the generate mappings - not the application.cfc mappings.
👍 1
b
Your
application.cfc
is completely unused in this context.
👍 1
This is really no different than if you were to open the CommandBox
REPL
and run
createOBject()
on a random CFC on your hard drive.
j
Hmm tweaking mapping didn't change anything - same error? Do I need a mapping for each object dir?
Copy code
docbox generate 
strategy=HTML 
source=/virtual/project/www/htdocs/admin/objects 
mappings:admin.objects=/virtual/project/www/htdocs/admin/objects  
excludes=modules 
strategy-outputDir=/virtual/project/www/htdocs/admin/foo 
strategy-projectTitle='Admin Docs'
b
What exactly is the error?
j
If I were to instantiate one of these I would do new admin.objects.foo()
Copy code
Warning! The following script has errors: admin.objects.foo
invalid component definition, can't find component [base]
b
Copy code
invalid component definition, can't find component [base]
Hmm, that doesn't appear to be using a CF mapping. Where does
base
live? is it simply in the same folder as
foo
?
Normally a direct relative path in extends or implements will resolve regardless of mappings
j
These aren't named particularly well but we have something like: /admin/objects/base.cfc /admin/objects/base/api.cfc /admin/objects/something.cfc - extends="base" /admin/objects/bar/somethingelse.cfc - extends="base.api" etc etc /admin/foo - just the temp directory I'm dumping the output into
LOL this seems like it should be something simple... trying various combos or path and mappings... and drilling down to just one object dir
@bdw429s I'm back to trying to get Docbox working after cf update fun 🙂 I'm now just focusing on one directory to simplify things as much as possible - but despite all my mapping attempts I still get this error: My setup:
Copy code
Mapping in Application.cfc
this.mappings["/"] = "/virtual/project/www/htdocs";

Directory structure:
/virtual/project/www/htdocs/admin/objects/Container.cfc
/virtual/project/www/htdocs/admin/objects/bs/Migration.cfc - Migration.cfc does NOT extend Container.cfc and is documented
/virtual/project/www/htdocs/admin/objects/bs/VolumeMigration.cfc - VolumeMigration.cfc extends Container.cfc and throws error

docbox generate strategy=HTML source=/virtual/project/www/htdocs/admin/objects/bs mappings:<http://admin.objects.bs|admin.objects.bs>=/virtual/project/www/htdocs/admin/objects/bs  excludes=modules strategy-outputDir=/virtual/project/www/htdocs/admin/docbox strategy-projectTitle='Admin Docs'

This runs and I get docs for everything that doesn't extend Container.cfc - those that do I get an error:

Warning! The following script has errors: admin.objects.bsVolumeMigration
invalid component definition, can't find component [Container]
b
What does the extends look like in volumeMIgration?
The error message implies it looks like
Copy code
component extends="container" {
but as container is up a directory higher, I don't understand how that would ever resolve
Also, in your app, is
/virtual/preject/www/htdocs
not your webroot?
I've always had issues in Lucee when overriding the
/
mapping
j
Yeah it is extends="Container"
b
So... how does that work in your app, lol?
Because that shouldn't work unless you have some sort of component paths setup or something
j
Thats a good question
b
Note, Lucee allows
extends="../myComponent"
j
Let me ask someone who has been here longer than me LOL This is running on CF2018
It's a bit weird how they have it wired up with old code and FW/1
So that extends="Container" works because we're doing this which apparently has been there like that forever... LOL Maybe I'd be better off running dropping docbox in my app - that has issues as well since we're in a container and when docbox tries to create the output dir it has issues but I can probably hack around that...
Copy code
this.customTagPaths = "/virtual/project/www/htdocs/admin/objects,/virtual/project/www/htdocs/admin/tags"
b
Yeah, custom tag paths do the same thing component paths do-- give additional locations to look up CFCs
We don't currently account for that in docbox 😕
This is part of what makes CFML code so difficult to run in a vacuum
You could hack it into the CLI, of course, but I haven't provide any built in way to the docbox command to affect that
Try running this prior to the docbox command
Copy code
repl 'application action="update" componentPaths="/virtual/project/www/htdocs/admin/objects,/virtual/project/www/htdocs/admin/tags";'
j
Well - that's progress I get a different error 🙂 Think this is related to an include. Let me hack on this some more tomorrow and I'll let you know if I get it working