Merge branch 'development_docusaurus_atlas' of github.com:incubaid/herolib into development_docusaurus_atlas
This commit is contained in:
5
examples/data/atlas/atlas_test.hero
Executable file
5
examples/data/atlas/atlas_test.hero
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env hero
|
||||
|
||||
!!atlas.scan git_url:"https://git.ourworld.tf/tfgrid/docs_tfgrid4/src/branch/main/collections/tests"
|
||||
|
||||
!!atlas.export destination: '/tmp/atlas_export'
|
||||
@@ -11,8 +11,36 @@ A lightweight document collection manager for V, inspired by doctree but simplif
|
||||
- **Type-Safe Access**: Get pages, images, and files with error handling
|
||||
- **Error Tracking**: Built-in error collection and reporting with deduplication
|
||||
|
||||
|
||||
## Quick Start
|
||||
|
||||
put in .hero file and execute with hero or but shebang line on top of .hero script
|
||||
|
||||
**Scan Parameters:**
|
||||
|
||||
- `name` (optional, default: 'main') - Atlas instance name
|
||||
- `path` (required when git_url not provided) - Directory path to scan
|
||||
- `git_url` (alternative to path) - Git repository URL to clone/checkout
|
||||
- `git_root` (optional when using git_url, default: ~/code) - Base directory for cloning
|
||||
- `meta_path` (optional) - Directory to save collection metadata JSON
|
||||
- `ignore` (optional) - List of directory names to skip during scan
|
||||
|
||||
|
||||
**most basic example**
|
||||
|
||||
```heroscript
|
||||
#!/usr/bin/env hero
|
||||
|
||||
!!atlas.scan git_url:"https://git.ourworld.tf/tfgrid/docs_tfgrid4/src/branch/main/collections/tests"
|
||||
|
||||
!!atlas.export destination: '/tmp/atlas_export'
|
||||
|
||||
```
|
||||
|
||||
put this in .hero file
|
||||
|
||||
## usage in herolib
|
||||
|
||||
```v
|
||||
import incubaid.herolib.data.atlas
|
||||
|
||||
@@ -455,54 +483,10 @@ save_path/
|
||||
└── collection3.json
|
||||
```
|
||||
|
||||
**Note:** Not in the collection directories themselves - saved to a separate location you specify.
|
||||
|
||||
### Limitations
|
||||
|
||||
- Load-from-JSON functionality is not yet implemented
|
||||
- Python loader is planned but not yet available
|
||||
- Currently, collections must be rescanned from source files
|
||||
## HeroScript Integration
|
||||
|
||||
Atlas integrates with HeroScript, allowing you to define Atlas operations in `.vsh` or playbook files.
|
||||
|
||||
### Available Actions
|
||||
|
||||
#### `atlas.scan` - Scan Directory for Collections
|
||||
|
||||
Scan a directory tree to find and load collections marked with `.collection` files.
|
||||
|
||||
```heroscript
|
||||
!!atlas.scan
|
||||
name: 'main'
|
||||
path: './docs'
|
||||
git_url: 'https://github.com/org/repo.git' # optional
|
||||
git_root: '~/code' # optional, default: ~/code
|
||||
meta_path: './metadata' # optional, saves metadata here
|
||||
ignore: ['private', 'draft'] # optional, directories to skip
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `name` (optional, default: 'main') - Atlas instance name
|
||||
- `path` (required when git_url not provided) - Directory path to scan
|
||||
- `git_url` (alternative to path) - Git repository URL to clone/checkout
|
||||
- `git_root` (optional when using git_url, default: ~/code) - Base directory for cloning
|
||||
- `meta_path` (optional) - Directory to save collection metadata JSON
|
||||
- `ignore` (optional) - List of directory names to skip during scan
|
||||
|
||||
### Real Workflow Example: Scan and Export
|
||||
|
||||
```heroscript
|
||||
!!atlas.scan
|
||||
path: '~/docs/myproject'
|
||||
meta_path: '~/docs/metadata'
|
||||
|
||||
!!atlas.export
|
||||
destination: '~/docs/output'
|
||||
include: true
|
||||
redis: false
|
||||
```
|
||||
|
||||
### Using in V Scripts
|
||||
|
||||
Create a `.vsh` script to process Atlas operations:
|
||||
@@ -515,12 +499,9 @@ import incubaid.herolib.data.atlas
|
||||
|
||||
// Define your HeroScript content
|
||||
heroscript := "
|
||||
!!atlas.scan
|
||||
path: './docs'
|
||||
!!atlas.scan path: './docs'
|
||||
|
||||
!!atlas.export
|
||||
destination: './output'
|
||||
include: true
|
||||
!!atlas.export destination: './output' include: true
|
||||
"
|
||||
|
||||
// Create playbook from text
|
||||
|
||||
Reference in New Issue
Block a user