Skip to content
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

Option and code to generate AsciiDoc friendly output #45

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

djencks
Copy link

@djencks djencks commented Jan 30, 2022

See #44

This does not currently include the two sets of AsciiDoc templates, as I'm not sure where they should go.

As noted in the issue, there is likely a better way to switch between text/Template and html/Template.

This is what I'm using for generating the Camel-K docs, and it's WIP, not a final proposal.

main.go Outdated
@@ -393,7 +408,7 @@ func apiGroupForType(t *types.Type, typePkgMap map[*types.Type]*apiPackage) stri

// anchorIDForLocalType returns the #anchor string for the local type
func anchorIDForLocalType(t *types.Type, typePkgMap map[*types.Type]*apiPackage) string {
return fmt.Sprintf("%s.%s", apiGroupForType(t, typePkgMap), t.Name.Name)
return sanitizeId(fmt.Sprintf("%s.%s", apiGroupForType(t, typePkgMap), t.Name.Name))
Copy link
Owner

@ahmetb ahmetb Jan 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a breaking change as I understand it, hence not quite desirable

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure if you'd consider this a breaking change: I have no problem changing it. I see three options:

  • introduce a sanitizeId function called from templates, similar to the asciiDocAttributeEscape method I introduced. This is certainly the least complex and most flexible, but increases the API exposed to templates.
  • sanitize ids based on the asciiDoc flag. This will probably end up with the most complex code, and will be the least flexible: perhaps users wanting html generation will want to have simplified IDs.
  • introduce a sanitizeId flag.

I lean towards the first solution, exposing a sanitizeId function to templates. What is your preference?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and pushed a commit to expose a sanitizeId method. I had to add a tryDereference to anchorIDForLocalType: I think exposing this to templates without the dereference was a bug.

Travis was using Go 1.11: I updated to 1.12 to allow use of strings.ReplaceAll. I'm not sure if there are other more modern API usages. Is updating the Go version OK?

@tadayosi
Copy link

Hi @ahmetb, this is important for us. Is there anything else we can do to get it merged?

@ahmetb
Copy link
Owner

ahmetb commented Jul 11, 2022

I am confused about the contents in the change.

It offers an asciidoc config option but there's no asciidoc related code.

Is this simply "disable markdown rendering"?

I am not willing to support AsciiDoc if it warrants a separate template. Many projects use md/html (see README) and this can become too much hassle to support properly.

Feel free to fork this tool as you see fit. I maintain this at a personal capacity anyway.

@JakeSCahill
Copy link

@djencks is the source available for the version that you forked for the Camel-K docs? I'm interested in trying this tool out for our project.

@djencks
Copy link
Author

djencks commented Jun 16, 2023

@JakeSCahill Sure, the appropriate branch in my fork is https://github.com/djencks/gen-crd-api-reference-docs/tree/main-asciidoc. I haven't updated it lately, and it appears to be behind the original project. I haven't looked to see if I should merge in the updates. Discussing that on my fork would be more appropriate than here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants