Skip to content

Commit

Permalink
👌 IMPROVE: Run cfformat to placate the format checker PR workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelborn committed Jul 24, 2023
1 parent 446e832 commit e294885
Show file tree
Hide file tree
Showing 14 changed files with 442 additions and 342 deletions.
31 changes: 19 additions & 12 deletions DocBox.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,16 @@ component accessors="true" {
*/
DocBox function generate(
required source,
string mapping = "",
string excludes = "",
string mapping = "",
string excludes = "",
boolean throwOnError = false
){
// verify we have at least one strategy defined, if not, auto add the HTML strategy
if ( isNull( getStrategies() ) || !getStrategies().len() ) {
this.addStrategy( strategy : "HTML", properties : variables.properties );
this.addStrategy(
strategy : "HTML",
properties: variables.properties
);
}

// inflate the incoming input and mappings
Expand All @@ -134,7 +137,11 @@ component accessors="true" {
}

// build metadata collection
var metadata = buildMetaDataCollection( thisSource, arguments.excludes, arguments.throwOnError );
var metadata = buildMetaDataCollection(
thisSource,
arguments.excludes,
arguments.throwOnError
);

getStrategies().each( function( strategy ){
strategy.run( metadata );
Expand Down Expand Up @@ -171,18 +178,18 @@ component accessors="true" {
*/
query function buildMetaDataCollection(
required array inputSource,
string excludes = "",
string excludes = "",
boolean throwOnError = false
){
var metadata = queryNew( "package,name,extends,metadata,type,implements,fullextends,currentMapping" );

// iterate over input sources
for ( var thisInput in arguments.inputSource ) {
if ( !directoryExists( thisInput.dir ) ){
if ( !directoryExists( thisInput.dir ) ) {
throw(
message = "Invalid configuration; source directory not found",
type = "InvalidConfigurationException",
detail ="Configured source #thisInput.dir# does not exist."
type = "InvalidConfigurationException",
detail = "Configured source #thisInput.dir# does not exist."
);
}
var aFiles = directoryList( thisInput.dir, true, "path", "*.cfc" );
Expand Down Expand Up @@ -267,11 +274,11 @@ component accessors="true" {
querySetCell( metadata, "extends", "-" );
}
} catch ( Any e ) {
if ( arguments.throwOnError ){
if ( arguments.throwOnError ) {
throw(
type = "InvalidComponentException",
message = e.message,
detail = e.detail,
type = "InvalidComponentException",
message = e.message,
detail = e.detail,
extendedInfo = serializeJSON( e )
);
} else {
Expand Down
20 changes: 14 additions & 6 deletions strategy/AbstractTemplateStrategy.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ component doc_abstract="true" accessors="true" {

/**
* Custom annotation for noting `abstract` components
*
*
* @url https://docbox.ortusbooks.com/getting-started/annotating-your-code#custom-docbox-blocks
*/
variables.META_ABSTRACT = "doc_abstract";

/**
* Custom annotation for noting generic method return types or argument types.
*
*
* @url https://docbox.ortusbooks.com/getting-started/annotating-your-code#custom-docbox-blocks
*/
variables.META_GENERIC = "doc_generic";
variables.META_GENERIC = "doc_generic";

/**
* Constructor
Expand Down Expand Up @@ -465,7 +465,11 @@ component doc_abstract="true" accessors="true" {
}

// Recursive function to output data
function writeItems( struct startingLevel, string packageTerm = "package", classTerm = "class" ){
function writeItems(
struct startingLevel,
string packageTerm = "package",
classTerm = "class"
){
for ( var item in startingLevel ) {
// Skip this key as it isn't a class, just the link for the package.
if ( item == "$link" ) {
Expand All @@ -479,7 +483,7 @@ component doc_abstract="true" accessors="true" {
writeOutput( "<li data-jstree='{ ""type"" : ""#arguments.classTerm#"" }' linkhref=""#linkData.link#"" searchlist=""#linkData.searchList#"" thissort=""2"">" );
writeOutput( item );
writeOutput( "</li>" );
// If this is a package, output it and its children
// If this is a package, output it and its children
} else {
var link = "";
if ( structKeyExists( itemValue, "$link" ) ) {
Expand All @@ -491,7 +495,11 @@ component doc_abstract="true" accessors="true" {
writeOutput( item );
writeOutput( "<ul>" );
// Recursive call
writeItems( itemValue, arguments.packageTerm, arguments.classTerm );
writeItems(
itemValue,
arguments.packageTerm,
arguments.classTerm
);
writeOutput( "</ul>" );
writeOutput( "</li>" );
}
Expand Down
Loading

0 comments on commit e294885

Please sign in to comment.