Skip to content

docs: update for objective method syntax and REPL highlighting#10

Merged
Almas-Ali merged 9 commits into
masterfrom
feature/update-latest-docs
May 9, 2026
Merged

docs: update for objective method syntax and REPL highlighting#10
Almas-Ali merged 9 commits into
masterfrom
feature/update-latest-docs

Conversation

@Almas-Ali

Copy link
Copy Markdown
Member

Summary

Major documentation update covering the new object-oriented method syntax and REPL improvements.

Changes

New Method Syntax Documentation

  • Updated arrays.md with built-in methods (.append(), .pop(), .sort(), .map(), .filter(), etc.)
  • Updated strings.md with string methods (.upper(), .lower(), .split(), .replace(), etc.)
  • Updated data-types.md with number and boolean methods
  • Updated built-in-functions.md to reflect removal of standalone arr_*/str_* functions
  • Updated standard-library.md and quick-start.md with new syntax examples

REPL Enhancement

  • Added Optional REPL Enhancement section to installation.md
  • Documents prompt_toolkit optional dependency for syntax highlighting

Syntax Highlighting

  • Enhanced radon-highlight.js with better grammar and color palette
  • Added integer division and compound assignment operators

Code Examples

  • Fixed indentation consistency across all examples
  • Corrected code examples and typos

- Added .gitignore to exclude virtual environment and site directory.
- Updated README.md for clarity and improved instructions for local development.
- Revised arrays.md to correct function names and enhance examples.
- Expanded built-in-functions.md with detailed descriptions and new functions.
- Improved classes.md for consistency in method descriptions.
- Added switch statement and assert statement sections to control-flow.md.
- Enhanced index.md with clearer project introduction and usage instructions.
- Updated installation.md to reflect current installation practices and requirements.
- Expanded language-reference.md with comprehensive language features and examples.
- Corrected loops.md to remove incorrect syntax and clarify loop behavior.
- Improved quick-start.md with a clear introduction and example usage.
- Expanded standard-library.md with module descriptions and usage examples.
- Updated strings.md to clarify string functions and add slicing examples.
- Restructured mkdocs.yml for better navigation and organization of documentation.
Rewrite radon-highlight.js and extra.css to use the same token color
palette as radon-project.github.io and the Radon REPL terminal.

radon-highlight.js:
- Inject !important CSS overrides at runtime to beat Material for MkDocs'
  bundled hljs theme rules, which override standard class names (.hljs-keyword,
  .hljs-string, .hljs-number, .hljs-comment, .hljs-operator) at higher cascade
  order. Non-standard names (.hljs-builtin, .hljs-fncall, .hljs-special,
  .hljs-punctuation) do not need !important.
- Rewrite grammar rule order (first-match wins): multi-line comment (#! … !#)
  → single-line comment (#) → string → builtin → keyword → number → special
  → fncall → operator → punctuation.
- Add multi-line comment rule (#! … !#) before single-line so #! is not
  consumed by the # rule.
- Expand keyword list from 6 to 30+ keywords sourced from core/tokens.py
  KEYWORDS list. Add 'as', 'elif', 'for', 'while', 'return', 'import',
  'from', 'in', 'and', 'or', 'not', 'try', 'catch', 'raise', 'break',
  'continue', 'const', 'static', 'assert', 'switch', 'case', 'default',
  'fallthrough', 'fallout', 'del', 'step', 'to'. Remove invalid 'end'.
  Add 'null', 'true', 'false', 'this', '__constructor__' as keyword-like.
- Add builtin class sourced from create_global_symbol_table() in
  core/builtin_funcs.py. Includes all 37 built-in functions plus 5 built-in
  classes: File, String, Json, Requests, builtins.
- Add fncall rule using lookahead (?=\s*\() so ( stays outside the span
  and falls through to punctuation.
- Add punctuation rule for {}()[],.;:
- Expand operator regex to cover multi-char operators (->, ++, --, ==, !=,
  <=, >=, +=, -=, *=, /=, %=) before single-char to prevent partial matches.
- Fix number regex to also match floats (\b\d+(?:\.\d+)?\b).
- Remove invalid hljs.IMMEDIATE_RE reference from string rule.
- Replace hljs.highlightAll() with explicit querySelectorAll targeting
  .language-text.highlight pre code blocks (MkDocs Pygments TextLexer
  fallback when no 'rn' lexer is registered) and re-highlight them as 'rn'
  using block.textContent to strip Pygments line-number anchors.

extra.css:
- Replace all token colors with the new palette matching radon-project.github.io.
- Add !important on .hljs-keyword, .hljs-string, .hljs-number, .hljs-comment,
  .hljs-operator as a CSS fallback matching the runtime JS injection.
- Add new rules: .hljs-builtin (#34d399), .hljs-punctuation (#94a3b8).
- Remove .hljs-function (replaced by .hljs-fncall + .hljs-special, both #c084fc).
- Set .hljs-identifier to inherit (no coloring for plain identifiers).

Token palette:
  keyword     #7dd3fc  sky-blue   bold
  builtin     #34d399  emerald
  string      #a3e635  lime-green
  number      #fb923c  orange
  operator    #f87171  salmon
  punctuation #94a3b8  slate-gray
  comment     #5c6591  slate-purple  italic
  fncall      #c084fc  violet
  special     #c084fc  violet
- control-flow.md: fix "In Rain" → "In Radon"
- data-types.md: add missing `var` declarations in array examples
- loops.md: add missing `var` on loop counter in while_break example
- classes.md: add missing `const` on Person instantiation example
- arrays.md: add missing `const` on Array stdlib usage example

All bare assignments (x = ...) have been updated to use the proper
`var`/`const` declaration keyword so examples match idiomatic Radon.
…operators

radon-highlight.js: extend the operator regex to include:
  - `//=`  integer division-assignment
  - `//`   integer floor division
  - `^=`   exponentiation-assignment

Ordering ensures `//=` is tested before `//`, and `//` before `/=`,
so each multi-char token is emitted as a single salmon-colored span
rather than two partial matches.
BREAKING CHANGE: Document removal of arr_*/str_* builtin functions

- Remove arr_append, arr_pop, arr_extend, arr_chunk, arr_get, arr_len docs
- Remove str_len, str_find, str_get docs
- Add Array methods reference (27 methods)
- Add String methods reference (25+ methods)
- Add Number methods reference (28 methods)
- Add Boolean methods reference (9 methods)
- Add HashMap methods reference (18 methods)
- Mark array/string stdlib modules as legacy
- Add 'Primitive Methods' section to built-in-functions.md
- Update quick-start.md example to use .length()
@Almas-Ali Almas-Ali merged commit a891135 into master May 9, 2026
1 check passed
@Almas-Ali Almas-Ali deleted the feature/update-latest-docs branch May 9, 2026 21:41
github-actions Bot added a commit that referenced this pull request May 9, 2026
docs: update for objective method syntax and REPL highlighting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant