DocstringTranslation.jl Documentation

DocstringTranslation.insertversion — Method
insertversion(svec::AbstractVector, v::VersionNumber)

Insert a version string into a copy of the given vector at the second position.

Arguments

  • svec::AbstractVector: The vector into which the version string will be inserted.
  • v::VersionNumber: The version number used to create the version string.

Returns

A new vector with the version string inserted at the second position.

Details

The function creates a deep copy of the input vector svec and inserts a string representation of the version number v in the format "major.minor" at the second position.

source
DocstringTranslation.pathofcachedir — Function
pathofcachedir(md::Markdown.MD, allowold::Bool=false)

Return a cache directory inside the configured root. Unversioned modules use the Julia version. Absolute and parent-relative page paths share a portable directory and are distinguished by content hash.

source
DocstringTranslation.prevminor — Method
prevminor(v::VersionNumber)

Return a VersionNumber with the same major version as v, but with minor version decremented by 1 (bounded at 0) and patch version set to 0.

source
DocstringTranslation.translate_documenter_page_with_openai — Method
translate_documenter_page_with_openai(source; max_attempts=3,
    fallback_model=default_fallback_model(), fallback_max_attempts=1)

Translate and validate using the primary model. Only after it fails, try the fallback model (by default GPT-6.1 Sol, medium reasoning) on the same pristine source. Both phases use identical Markdown validation; neither caches bad output. Set the fallback model to nothing to disable escalation.

An injected request(text, promptfn) disables automatic network fallback unless fallback_request is supplied explicitly. This keeps custom providers and offline tests in control of all external requests.

source
DocstringTranslation.translate_pages — Method
DocstringTranslation.translate_pages(paths; concurrency=32)

Translate Markdown files into the current language and populate the same cache used by @switchlang! and Documenter. Run this before Documenter.makedocs to overlap API requests across pages. Up to concurrency asynchronous workers run even with one Julia thread; concurrency must be a positive integer.

Return (translated, cached, failed) in input order. The first two fields are vectors of absolute file paths. failed contains path => exception pairs. Individual failures do not discard successful peers; rerun the batch to resume. Duplicate paths (including symlinks) are processed once per call. An empty input returns empty vectors. Without OPENAI_API_KEY, cached pages remain usable and uncached pages are reported as failures.

Set the language with @switchlang!, and configure the cache directory, target package and model before calling. Keep that configuration fixed until the batch completes. Concurrent calls have independent worker limits and do not deduplicate each other's requests.

For custom providers or offline testing, request(text, promptfn) may supply the response text, with available=true to enable it without an API key. Responses undergo the same protection and validation as ordinary page translations.

source
DocstringTranslation.@switchlang! — Macro
@switchlang!(lang)

Switch the target language for docstring translation and modify the documentation system to automatically translate docstrings.

Arguments

  • lang: The target language code (e.g., "ja", "en") to translate docstrings into.

Details

This macro performs the following operations:

  1. Sets the target language for translation
  2. Overrides Docs.parsedoc to insert translation engine for individual docstrings
  3. Overrides Documenter.Page constructor to enable translation of entire documentation pages

Translation failures produce a warning and fall back to pristine original Markdown; they never become translated cache entries. Inspect DocstringTranslation.translation_failures() and clear failures between builds with DocstringTranslation.clear_translation_failures!().

Example

@switchlang! "ja"  # Switch to Japanese translation
source