AemieJ commented on pull request #3860:
URL: https://github.com/apache/camel/pull/3860#issuecomment-634459112


   > I appreciate you showing your code, but please use markdown on text; 
surround the text with ```.
   > 
   > Your code looks like it would work, but I think it is rather fragile. 
Perhaps we need some more opinions.
   
   @djencks , as the summary method is fragile, we could use the attribute 
naming that you suggested. What we could do is as each component is manually 
written and each has constant variable declared as docTitle, what we could do 
is divide files into parentGroup and childGroup variables, and check whether it 
is parent attribute or child using the following logic. 
   
   ```
   function isParentAttribute(file) {
       var attributeName = /(?::parentGroup: 
)(.*)/.exec(file.contents.toString())
       if (attributeName != null) {
           return attributeName[1];
       }
       return null;
   }
   
   function isChildAttribute(file) {
       var attributeName = /(?::childGroup: 
)(.*)/.exec(file.contents.toString())
       if (attributeName != null && attributeName[1] == parentAttribute) {
           return true;
       }
       return false;
   }
   ```
   
   Then while the distribution logic takes place to generate the adoc file, we 
could use the following logic of if and else: 
   
   ```
   if (isParentAttribute(file) != null) {
        parentAttribute = isParentAttribute(file);
   } else if (isChildAttribute(file)) {
        return `*** xref:${filepath}[${title}]`;
   }
   return `** xref:${filepath}[${title}]`;
   ```
   With this manner, it would be accurate and the code will never fail for any 
test. This method works as I tried it on my code editor. If you like this, we 
could follow up with this.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to