asciidoctor / asciidoclet

:clipboard: A Javadoc Doclet based on Asciidoctor that lets you write Javadoc in the AsciiDoc syntax.
https://github.com/asciidoctor/asciidoclet
Apache License 2.0
133 stars 40 forks source link

Set attribute `env-asciidoclet` by default #57

Closed lefou closed 8 years ago

lefou commented 8 years ago

This would ease custom processing for Javadoc, e.g. with ifdef::.

johncarl81 commented 8 years ago

Do other libraries in the asciidoctor ecosystem set a similar attribute?

lefou commented 8 years ago

Yes. E.g. on GitHub, there is env-github. The asciidoctor plugin for gitbucket sets env-gitbucket.

See also http://asciidoctor.org/news/2014/02/04/github-asciidoctor-0.1.4-upgrade-5-things-to-know/#long-live-asciidoc-on-github

lefou commented 8 years ago

Additionally, env=asciidoclet would be a good idea too.

johncarl81 commented 8 years ago

WDYT?: #58

johncarl81 commented 8 years ago

setting env has the possibility to collide between libraries btw. Asciidoclet uses Asciidoctorj, which I imagine could set a similar env=asciidoctorj.

johncarl81 commented 8 years ago

@lefou, Im curious, what is your use-case for this?

lefou commented 8 years ago

asciidoctorj does not set env attribute, and current usage of the env attribute in other places (and my conversations with @mojavelinux ) suggest it is meant the way we want it to use it here. Also gitbucket-asciidoctor-plugin is also based on asciidoctorj.

My current use case was reusing the project README.adoc, which is the entry point documentation on GitHub, also as the overview page in the JavaDoc. Of course some links are different and need to be handled conditionally for each environment. E.g. src/main/java prefix or not, .java or .html file ending, etc.

ifdef::env-github,env-gitbucket[:outfilesuffix: .adoc]
ifndef::env-asciidoclet[:srcdir: src/main/java/]
ifdef::env-asciidoclet[:srcdir:]
ifndef::env-asciidoclet[:javasuffix: .java]
ifdef::env-asciidoclet[:javasuffix: .html]

link:{srcdir}org/example/Main{javasuffix}[`Main`]
johncarl81 commented 8 years ago

Makes sense.

mojavelinux commented 8 years ago

:+1:

mojavelinux commented 8 years ago

Correct. env is the execution environment, not which implementation of the processor is being used. In other words, it describes where the document is being converted. We set this in plugins such as a static site generator, so it makes a lot of sense to set it here too.