Skip to content

Plugin Configuration Module

This section is about the module that plays the role to handle the plugin configuration which independent from the plugin core.

It will be called by plugin core and CLI directly.

MkdocsNoteConfig

Bases: Config

Configuration class, managing all configuration parameters.

Source code in src/mkdocs_note/config.py
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
class MkdocsNoteConfig(Config):
	"""Configuration class, managing all configuration parameters."""

	enabled = config_opt.Type(bool, default=True)
	"""Whether the plugin is enabled.
    """

	notes_root = config_opt.Dir(exists=False, default="docs")
	"""The directory of the notes, which defines the plugin's working scope.
    All note scanning, file operations, and asset management are limited to this directory.
    """

	recent_notes_config = config_opt.Type(
		dict,
		default={
			"enabled": False,
			"insert_marker": "<!-- recent_notes -->",
			"insert_num": 10,
		},
	)
	"""Configuration for the recent notes.
    Available options:
    - enabled: Whether to enable the recent notes
    - insert_marker: The marker to insert the recent notes
    - insert_num: The number of recent notes to insert
    """

	# Network Graph Configuration
	graph_config = config_opt.Type(
		dict,
		default={
			"enabled": False,
			"name": "title",  # Node naming strategy: "title" or "file_name"
			"debug": False,  # Enable debug logging for graph generation
		},
	)
	"""Configuration for the network graph visualization.

    Available options:
    - name: Node naming strategy ("title" or "file_name")
    - debug: Enable debug logging for graph generation
    """

	preview_config = config_opt.Type(
		dict,
		default={
			"enabled": False,
			"mode": "summary",  # summary | excerpt
			"delay_ms": 300,
			"max_chars": 200,
			"include_fragments": True,
			"mobile": False,
			"scope": "linked_only",  # linked_only | all
		},
	)
	"""Configuration for same-site link hover previews.

    Available options:
    - enabled: Opt-in; when false the feature is a full no-op
    - mode: ``summary`` (title + abstract) or ``excerpt`` (section body / HTML)
    - delay_ms: Hover delay before showing the card
    - max_chars: Truncation length for plain-text summaries / excerpts
    - include_fragments: Emit ``#heading`` keys when mode is excerpt
    - mobile: Enable touch preview strategy (default off)
    - scope: ``linked_only`` (link targets only) or ``all`` pages
    """

	encryption_config = config_opt.Type(
		dict,
		default={
			"kdf_iterations": 600_000,
			"remember": "session",  # session | local | none
			"strict": "auto",  # auto | true | false
			"rerender": True,
			"audit": True,
			"labels": dict(DEFAULT_LABELS),
		},
	)
	"""Configuration for per-note page encryption.

    Encryption is opted into per note with ``encrypt: true`` in the note's
    frontmatter; this block only tunes the browser experience and the guard
    rails. Available options:
    - kdf_iterations: PBKDF2-HMAC-SHA256 iterations for the browser payload
    - remember: Where to cache the derived key (``session``/``local``/``none``)
    - strict: Fail the build for plaintext/undecryptable encrypted notes;
      ``auto`` enables it when the ``CI`` environment variable is truthy
    - rerender: Call ``document$.next(document)`` after decrypting so Material
      and user scripts re-initialize the revealed content
    - audit: Warn when plaintext of an encrypted note is found in the built site
    - labels: UI strings for the lock form (English defaults)
    """

	notion_sync = config_opt.Type(
		dict,
		default={
			"docs_dir": "docs",
			"nav_file": "docs/.nav.yml",
			"database_id": "",
			"data_source_id": "",
			"title_property": "页面",
			"tags_property": "标签",
			"site_url": "",
			"state_path": ".notion_sync_state.json",
			"delay": 0.35,
			"local_images": "upload",
			"cache_dir": ".cache/mkdocs-note",
			"allow_cursor_mcp_token": False,
			"silence_mcp_token_warning": False,
		},
	)
	"""Configuration for Notion wiki sync (CLI: ``mkdocs-note notion-sync``).

    Available options:
    - docs_dir: Documentation root (git diff / relative path base)
    - nav_file: Path to awesome-nav ``.nav.yml`` (relative to project root)
    - database_id: Notion wiki database / page ID (or env NOTION_WIKI_DATABASE)
    - data_source_id: Notion data source ID (or env NOTION_WIKI_DATA_SOURCE)
    - title_property: Title property name (default: 页面)
    - tags_property: Multi-select tags property name (default: 标签)
    - site_url: Public site URL for remote image fallbacks
    - state_path: Local page-map JSON path
    - delay: Seconds between Notion API calls
    - local_images: ``upload`` local files, or ``site`` to use MkDocs site URLs
    - cache_dir: Directory for ``--full`` resume checkpoints
    - allow_cursor_mcp_token: Developer-only; allow reading token from Cursor mcp.json
    - silence_mcp_token_warning: Suppress the MCP-token usage warning
    """

enabled = config_opt.Type(bool, default=True) class-attribute instance-attribute

Whether the plugin is enabled.

encryption_config = config_opt.Type(dict, default={'kdf_iterations': 600000, 'remember': 'session', 'strict': 'auto', 'rerender': True, 'audit': True, 'labels': dict(DEFAULT_LABELS)}) class-attribute instance-attribute

Configuration for per-note page encryption.

Encryption is opted into per note with encrypt: true in the note's frontmatter; this block only tunes the browser experience and the guard rails. Available options: - kdf_iterations: PBKDF2-HMAC-SHA256 iterations for the browser payload - remember: Where to cache the derived key (session/local/none) - strict: Fail the build for plaintext/undecryptable encrypted notes; auto enables it when the CI environment variable is truthy - rerender: Call document$.next(document) after decrypting so Material and user scripts re-initialize the revealed content - audit: Warn when plaintext of an encrypted note is found in the built site - labels: UI strings for the lock form (English defaults)

graph_config = config_opt.Type(dict, default={'enabled': False, 'name': 'title', 'debug': False}) class-attribute instance-attribute

Configuration for the network graph visualization.

Available options: - name: Node naming strategy ("title" or "file_name") - debug: Enable debug logging for graph generation

notes_root = config_opt.Dir(exists=False, default='docs') class-attribute instance-attribute

The directory of the notes, which defines the plugin's working scope. All note scanning, file operations, and asset management are limited to this directory.

notion_sync = config_opt.Type(dict, default={'docs_dir': 'docs', 'nav_file': 'docs/.nav.yml', 'database_id': '', 'data_source_id': '', 'title_property': '页面', 'tags_property': '标签', 'site_url': '', 'state_path': '.notion_sync_state.json', 'delay': 0.35, 'local_images': 'upload', 'cache_dir': '.cache/mkdocs-note', 'allow_cursor_mcp_token': False, 'silence_mcp_token_warning': False}) class-attribute instance-attribute

Configuration for Notion wiki sync (CLI: mkdocs-note notion-sync).

Available options: - docs_dir: Documentation root (git diff / relative path base) - nav_file: Path to awesome-nav .nav.yml (relative to project root) - database_id: Notion wiki database / page ID (or env NOTION_WIKI_DATABASE) - data_source_id: Notion data source ID (or env NOTION_WIKI_DATA_SOURCE) - title_property: Title property name (default: 页面) - tags_property: Multi-select tags property name (default: 标签) - site_url: Public site URL for remote image fallbacks - state_path: Local page-map JSON path - delay: Seconds between Notion API calls - local_images: upload local files, or site to use MkDocs site URLs - cache_dir: Directory for --full resume checkpoints - allow_cursor_mcp_token: Developer-only; allow reading token from Cursor mcp.json - silence_mcp_token_warning: Suppress the MCP-token usage warning

preview_config = config_opt.Type(dict, default={'enabled': False, 'mode': 'summary', 'delay_ms': 300, 'max_chars': 200, 'include_fragments': True, 'mobile': False, 'scope': 'linked_only'}) class-attribute instance-attribute

Configuration for same-site link hover previews.

Available options: - enabled: Opt-in; when false the feature is a full no-op - mode: summary (title + abstract) or excerpt (section body / HTML) - delay_ms: Hover delay before showing the card - max_chars: Truncation length for plain-text summaries / excerpts - include_fragments: Emit #heading keys when mode is excerpt - mobile: Enable touch preview strategy (default off) - scope: linked_only (link targets only) or all pages

recent_notes_config = config_opt.Type(dict, default={'enabled': False, 'insert_marker': '<!-- recent_notes -->', 'insert_num': 10}) class-attribute instance-attribute

Configuration for the recent notes. Available options: - enabled: Whether to enable the recent notes - insert_marker: The marker to insert the recent notes - insert_num: The number of recent notes to insert