Allow markdown and python files to be referenced direclty and add it to

the docs

Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
Francisco Javier Arceo 2025-10-21 10:14:15 -04:00
parent 7ab63068f8
commit 9ccd2e4e9b
11 changed files with 493 additions and 1145 deletions

View file

@ -15,16 +15,39 @@ You can open up the docs in your browser at http://localhost:3000
## File Import System
This documentation uses a custom component to import files directly from the repository, eliminating copy-paste maintenance:
This documentation uses `remark-code-import` to import files directly from the repository, eliminating copy-paste maintenance. Files are automatically embedded during build time.
```jsx
import CodeFromFile from '@site/src/components/CodeFromFile';
### Importing Code Files
<CodeFromFile src="path/to/file.py" />
<CodeFromFile src="README.md" startLine={1} endLine={20} />
To import Python code (or any code files) with syntax highlighting, use this syntax in `.mdx` files:
```markdown
```python file=./demo_script.py title="demo_script.py"
```
```
Files are automatically synced from the repo root when building. See the `CodeFromFile` component for syntax highlighting, line ranges, and multi-language support.
This automatically imports the file content and displays it as a formatted code block with Python syntax highlighting.
**Note:** Paths are relative to the current `.mdx` file location, not the repository root.
### Importing Markdown Files as Content
For importing and rendering markdown files (like CONTRIBUTING.md), use the raw-loader approach:
```jsx
import Contributing from '!!raw-loader!../../../CONTRIBUTING.md';
import ReactMarkdown from 'react-markdown';
<ReactMarkdown>{Contributing}</ReactMarkdown>
```
**Requirements:**
- Install dependencies: `npm install --save-dev raw-loader react-markdown`
**Path Resolution:**
- For `remark-code-import`: Paths are relative to the current `.mdx` file location
- For `raw-loader`: Paths are relative to the current `.mdx` file location
- Use `../` to navigate up directories as needed
## Content