mirror of
https://github.com/kjanat/articulate-parser.git
synced 2026-01-16 07:42:09 +01:00
Add comprehensive unit tests for services and main package
- Implement tests for the app service, including course processing from file and URI. - Create mock implementations for CourseParser and Exporter to facilitate testing. - Add tests for HTML cleaner service to validate HTML content cleaning functionality. - Develop tests for the parser service, covering course fetching and loading from files. - Introduce tests for utility functions in the main package, ensuring URI validation and string joining. - Include benchmarks for performance evaluation of key functions.
This commit is contained in:
92
README.md
92
README.md
@ -5,10 +5,8 @@ A Go-based parser that converts Articulate Rise e-learning content to various fo
|
||||
[][gomod]
|
||||
[][Package documentation]
|
||||
[][Go report]
|
||||
[][Tags]
|
||||
[][Latest release]
|
||||
[](LICENSE)
|
||||
[][Commits]
|
||||
[][Tags] <!-- [][Latest release] -->
|
||||
[][MIT License] <!-- [][Commits] -->
|
||||
[][Commits]
|
||||
[][Issues]
|
||||
[][Build]
|
||||
@ -29,20 +27,50 @@ A Go-based parser that converts Articulate Rise e-learning content to various fo
|
||||
|
||||
## Installation
|
||||
|
||||
1. Ensure you have Go 1.21 or later installed
|
||||
2. Clone or download the parser code
|
||||
3. Initialize the Go module:
|
||||
### Prerequisites
|
||||
|
||||
- Go, I don't know the version, but I use go1.24.2 right now, and it works, see the [CI][Build] workflow where it is tested.
|
||||
|
||||
### Install from source
|
||||
|
||||
```bash
|
||||
go mod init articulate-parser
|
||||
go mod tidy
|
||||
git clone https://github.com/kjanat/articulate-parser.git
|
||||
cd articulate-parser
|
||||
go mod download
|
||||
go build -o articulate-parser main.go
|
||||
```
|
||||
|
||||
### Or install directly
|
||||
|
||||
```bash
|
||||
go install github.com/kjanat/articulate-parser@latest
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
The parser uses the following external library:
|
||||
|
||||
- `github.com/unidoc/unioffice` - For creating Word documents
|
||||
- `github.com/fumiama/go-docx` - For creating Word documents (MIT license)
|
||||
|
||||
## Testing
|
||||
|
||||
Run the test suite:
|
||||
|
||||
```bash
|
||||
go test ./...
|
||||
```
|
||||
|
||||
Run tests with coverage:
|
||||
|
||||
```bash
|
||||
go test -v -race -coverprofile=coverage.out ./...
|
||||
```
|
||||
|
||||
View coverage report:
|
||||
|
||||
```bash
|
||||
go tool cover -html=coverage.out
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
@ -54,9 +82,11 @@ go run main.go <input_uri_or_file> <output_format> [output_path]
|
||||
|
||||
#### Parameters
|
||||
|
||||
- `input_uri_or_file`: Either an Articulate Rise share URL or path to a local JSON file
|
||||
- `output_format`: `md` for Markdown or `docx` for Word Document
|
||||
- `output_path`: Optional. If not provided, files are saved to `./output/` directory
|
||||
| Parameter | Description | Default |
|
||||
| ------------------- | ---------------------------------------------------------------- | --------------- |
|
||||
| `input_uri_or_file` | Either an Articulate Rise share URL or path to a local JSON file | None (required) |
|
||||
| `output_format` | `md` for Markdown or `docx` for Word Document | None (required) |
|
||||
| `output_path` | Path where output file will be saved. | `./output/` |
|
||||
|
||||
#### Examples
|
||||
|
||||
@ -75,7 +105,7 @@ go run main.go "articulate-sample.json" docx "my-course.docx"
|
||||
3. **Parse from local file and export to Markdown:**
|
||||
|
||||
```bash
|
||||
go run main.go "C:\Users\kjana\Projects\articulate-parser\articulate-sample.json" md
|
||||
go run main.go "articulate-sample.json" md "output.md"
|
||||
```
|
||||
|
||||
### Building the Executable
|
||||
@ -92,9 +122,29 @@ Then run:
|
||||
./articulate-parser input.json md output.md
|
||||
```
|
||||
|
||||
## Development
|
||||
|
||||
### Code Quality
|
||||
|
||||
The project maintains high code quality standards:
|
||||
|
||||
- Cyclomatic complexity ≤ 15 (checked with [gocyclo](https://github.com/fzipp/gocyclo))
|
||||
- Race condition detection enabled
|
||||
- Comprehensive test coverage
|
||||
- Code formatting with `gofmt`
|
||||
- Static analysis with `go vet`
|
||||
|
||||
### Contributing
|
||||
|
||||
1. Fork the repository
|
||||
2. Create a feature branch
|
||||
3. Make your changes
|
||||
4. Run tests: `go test ./...`
|
||||
5. Submit a pull request
|
||||
|
||||
## Output Formats
|
||||
|
||||
### Markdown (.md)
|
||||
### Markdown (`.md`)
|
||||
|
||||
- Hierarchical structure with proper heading levels
|
||||
- Clean text content with HTML tags removed
|
||||
@ -103,7 +153,7 @@ Then run:
|
||||
- Media references included
|
||||
- Course metadata at the top
|
||||
|
||||
### Word Document (.docx)
|
||||
### Word Document (`.docx`)
|
||||
|
||||
- Professional document formatting
|
||||
- Bold headings and proper typography
|
||||
@ -167,6 +217,13 @@ The parser includes error handling for:
|
||||
- Styling and visual formatting is not preserved
|
||||
- Assessment logic and interactivity is lost in static exports
|
||||
|
||||
## Performance
|
||||
|
||||
- Lightweight with minimal dependencies
|
||||
- Fast JSON parsing and export
|
||||
- Memory efficient processing
|
||||
- No external license requirements
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
Potential improvements could include:
|
||||
@ -188,6 +245,7 @@ This is a utility tool for educational content conversion. Please ensure you hav
|
||||
[Go report]: https://goreportcard.com/report/github.com/kjanat/articulate-parser
|
||||
[gomod]: go.mod
|
||||
[Issues]: https://github.com/kjanat/articulate-parser/issues
|
||||
[Latest release]: https://github.com/kjanat/articulate-parser/releases/latest
|
||||
<!-- [Latest release]: https://github.com/kjanat/articulate-parser/releases/latest -->
|
||||
[MIT License]: LICENSE
|
||||
[Package documentation]: https://godoc.org/github.com/kjanat/articulate-parser
|
||||
[Tags]: https://github.com/kjanat/articulate-parser/tags
|
||||
|
||||
Reference in New Issue
Block a user