-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
Yard's meta data make AsciiDoc render ugly when used outside Yard #1192
Comments
What I'd really like to see is YARD making use of the AsciiDoc header attributes. Then, it would be possible to pass data explicitly to YARD as follows:
(though it should use the implicit attributes like doctitle, author if no specific overrides are given). |
This is also an interesting idea, especially that it can be considered a non-breaking change, which is important in context of #1200 (comment). I support this proposal very much, although it somewhat feels like doing Yard things with non-yard markup. IMHO, for maximum compatibility, document meta tags should be resolved in following order of precedence:
* By "attribute" I mean AsciiDoc attributes, but also their possible counterparts in other markups, if they exist. I think I'll find some time to implement either @mojavelinux's idea, or "2 newlines" option (see that aforementioned comment and PR #1200 as whole), or both, depending on @lsegal's opinion on this topic. |
@lsegal Any opinion on @mojavelinux's idea? I believe I can implement either. |
I've done some research on this topic. How it works nowCurrently, the process of YARD documentation generation is roughly like this:
In this algorithm, extra file object titles must be known before step 4. begins. This is because the final documentation may contain some navigation controls, which may include links to any other extra file object. This is particularly true in case of HTML output. Consequently, document metadata cannot obtained from AsciiDoc processor (via its What we can do about itOption 1: Enhance regexpRegular expressions used in step 2 can be improved to parse AsciiDoc's attribute syntax. However, due to the complexity of AsciiDoc syntax, it is not easy to write a proper regular expression. Consider following example: = Some Document
:arbitrary-attr: This is value for the "arbitrary-attr" attribute
:yard-title: This is value for the "yard-title" attribute
Lead paragraph
[source]
--------------------------------------------------------------------------------
:yard-title: This is just a code sample, not an attribute definition for
the current document.
-------------------------------------------------------------------------------- In the above example, Instead of making the regular expression more complicated, I propose adding an additional requirement: that YARD-specific attributes must be defined before the first line which is not a section title nor another attribute definition. I don't think that any fancy techniques are really needed in these attributes, therefore in my opinion such constraint is acceptable. Option 2: Run Asciidoctor twiceAsciidoctor processor is run for the first time in step 2, and then again in step 4. The first run does not produce any output document, it is only to parse the source document and to extract YARD-specific attributes. This is a full-featured solution, which honours AsciiDoc's conditional processing, include directives, etc. No special constraints are required. Obviously some overhead is involved, but IMHO it is acceptable. Option 3: Render contents of extra file objects earlierMarkup processors for extra file objects are run at step 2 or 3 instead of step 4. Generated output is stored in a variable and merged into template at step 4. @mojavelinux, @lsegal, thoguhts? |
Asciidoctor already provides a mode to only parse the header, which is extremely lightweight. See the Keep in mind that the header ends at the first blank line after the document title, so the attribute entries must be compacted and directly adjacent to the document title. |
Yard supports meta tags in textual documents. For instance, one could be annotated as follows:
The problem is that this special markup breaks output outside Yard, i.e. in GitHub. In Markdown, a regular HTML comment can be used to workaround this problem:
However, in AsciiDoc nothing helps.
Attempt 1: HTML comments
All works correct in Yard. However, outside Yard HTML tags are escaped, which results with even uglier output:
Attempt 2: AsciiDoc comments
Document looks good both in Yard and outside it, but document title remains unchanged (equals to file name).
Attempt 3: AsciiDoc conditional processing
Document looks good in Yard, but its title remains unchanged.
The text was updated successfully, but these errors were encountered: