Package 'deephelp'

Title: Translate R Help Pages to Chinese with 'DeepSeek'
Description: Renders on-the-fly Simplified-Chinese translations of R help pages in the help pane of 'RStudio' or 'Positron', using the 'DeepSeek' chat model with reasoning (thinking mode) disabled for fast, low-cost, clean output. Works as a drop-in replacement for ? and help(). Translations are cached on disk.
Authors: Xing Shi [aut, cre]
Maintainer: Xing Shi <[email protected]>
License: MIT + file LICENSE
Version: 0.3.5
Built: 2026-11-25 18:29:30 UTC
Source: https://github.com/cran/deephelp

Help Index


Translate and display an R help page in Chinese

Description

Translate and display an R help page in Chinese

Usage

deephelp(topic, package = NULL, lang = NULL, type = NULL, ...)

Arguments

topic

A name or character string specifying the help topic.

package

Optional package name. If 'NULL', loaded packages are searched.

lang

Target language. Defaults to the value set via [deephelp_use()].

type

Output type: '"html"' (default, opens the translated page in the Help pane of RStudio or Positron) or '"text"' (prints plain text).

...

Currently ignored.

Value

An object of class '"deephelp_topic"', a list with components 'topic', 'package', 'rd' (the parsed, translated Rd object) and 'type'. It has a 'print()' method that renders the translated help page. On error, the call falls back to [utils::help()] and returns its value instead.


Clear the translation cache

Description

Clear the translation cache

Usage

deephelp_clear_cache(cache = NULL)

Arguments

cache

Cache directory to clear. Defaults to the current cache location.

Value

Invisibly 'NULL'. Called for its side effect of deleting the on-disk translation cache.


Disable automatic translation of '?' and 'help()'

Description

Disable automatic translation of '?' and 'help()'

Usage

deephelp_off()

Value

Invisibly 'FALSE'. Called for its side effect of disabling automatic translation.


Enable automatic translation of '?' and 'help()'

Description

Enable automatic translation of '?' and 'help()'

Usage

deephelp_on()

Value

Invisibly 'TRUE'. Called for its side effect of enabling automatic translation and attaching the '?'/'help()' shims.


Print the current configuration

Description

Print the current configuration

Usage

deephelp_status()

Value

Invisibly, the current configuration as a named list. Called for its side effect of printing the configuration.

Examples

deephelp_status()

Configure the DeepSeek backend

Description

Configure the DeepSeek backend

Usage

deephelp_use(
  api_key = NULL,
  model = NULL,
  base_url = NULL,
  lang = NULL,
  cache = NULL,
  temperature = NULL,
  max_tokens = NULL,
  timeout = NULL,
  cjk_spacing = NULL,
  glossary = NULL
)

Arguments

api_key

DeepSeek API key. Falls back to 'getOption("deephelp.api_key")' and then the 'DEEPSEEK_API_KEY' environment variable.

model

Model name. Defaults to '"deepseek-flash"' (fast, cheap, non-reasoning). Use '"deepseek-v4-pro"' for higher quality at higher cost.

base_url

API base URL. Defaults to '"https://api.deepseek.com"'.

lang

Target language. Defaults to Simplified Chinese.

cache

Cache directory. 'NULL' uses the default location; '""' disables caching; otherwise a directory path.

temperature

Optional sampling temperature passed to the API.

max_tokens

Optional maximum number of output tokens.

timeout

HTTP timeout in seconds.

cjk_spacing

Logical. Insert consistent single spaces between Chinese and Latin letters/digits (and around code) in the translated output. Defaults to 'TRUE'.

glossary

Named character vector mapping English statistical terms to Chinese translations. Merged over the built-in glossary; use 'character(0)' to disable the glossary entirely.

Value

Invisibly, the updated configuration as a named list. Called for its side effect of updating the stored configuration and printing the new status via [deephelp_status()].