Skip to content

javadoc and XML docs render authored Markdown literally: the Formula block welds prose, and emphasis ships as asterisks #404

Description

@mario4tier

The canonical input/<name>/<name>.md is Markdown. Rust's target is Markdown too, so rustdoc renders it. Java's target is HTML and C#'s is XML, and their emitters convert only part of it — so the rest ships to users as literal punctuation, in the published javadoc, the NuGet XML docs, and every IDE hover.

Two independent causes, both measured on dev at e63a7218b.

1. ## Formula welds its trailing prose into the code block

parser::doc_md::split_formula_note separates the formula from the sentence after it only when the section carries a closing $$. Across the corpus, 2 of 150 ## Formula sections do. For the other 148 the whole section — formula and every prose paragraph under it — is handed to the emitters as preformatted text.

62 lines land inside <pre>{@code} in Core.java, and 62 inside <code> in the C# sources, across 22 indicators: ADR ADX APO ATR CMOU COPPOCK CUMSUM DPO EFI EMA ER ERI FRACTAL MIDPRICE PPO PVO QSTICK RVI VHF VORTEX VWMA WAD.

Core.java, COPPOCK:

* <p><b>Formula</b>
* <pre>{@code
* `COPPOCK = WMA(ROC(optInROC1Period) + ROC(optInROC2Period), optInWMAPeriod)`
* Each ROC carries [`ROC`](/functions/roc)'s own zero guard — a zero price `optInROC*Period` bars back yields 0.0 …
* The formula is symmetric in the two ROC periods and the lookback keys off their max, so `optInROC1Period > …
* The classic defaults are 11/14/10 on monthly data. Wikipedia's daily-scale variant (231/294-bar ROC, 210-bar …
* }</pre>

Three prose paragraphs as code, the formula keeping its literal backticks, and a Markdown link as text. The same source renders correctly on ta-lib.org (website/src/functions/coppock.md), which is what says the .md is right and the emitters are wrong.

This is also why 6 Markdown links survived the conversion added in #386 (e46e97c0a): they sit inside the formula block, which never reaches jdoc/csdoc. COPPOCK, ERI and VORTEX, x2 overloads.

2. Markdown emphasis ships literally into ordinary prose

jdoc and csdoc convert backtick spans and (since e46e97c0a) inline links. They do not convert **bold** or *italic*, so those reach the reader as asterisks — this time outside any code block, in summaries and notes.

**bold** *italic*
Java Core.java 16 39
C# Core_*.cs 16 38

e.g. weighted moving average of the **sum** of two rates of change and how far price travels *within* a bar.

Rust's counts are non-zero too and are correct — rustdoc renders Markdown. Only the HTML and XML targets need the conversion.

Nothing catches either

Measured, not assumed: javadoc -Xdoclint:all,-missing (the setting pom.xml enforces) and csc under TreatWarningsAsErrors + GenerateDocumentationFile both accept literal Markdown without a diagnostic. regen-check only pins that the committed output matches the emitter, so it agrees with whatever is emitted. This is the same blind spot #386 hit with links, where Rust was clean only because rustdoc's bare_urls lint made a stranded URL a build failure.

What a fix has to decide

  • split_formula_note needs a second delimiter form — a formula line followed by a blank line and prose. That changes what 148 functions render as a formula in four backends, so it wants its own before/after diff review rather than being folded into a doc-emitter change.
  • Emphasis conversion is local to jdoc/csdoc (<b>/<i>), and is the smaller half. It can land independently.
  • Rust must not change: it already receives Markdown and wants it.

Guard the result with a unit test on the escapers plus a corpus assertion that no rendered Java/C# doc line carries **, ](, or a stray backtick outside a code block — nothing else can see this class.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions