- TypeScript 99.8%
- JavaScript 0.2%
chore(deps): update dependency @redocly/cli to v2.14.2 See merge request logius/nldoc/spec/document!404 |
||
|---|---|---|
| .vscode | ||
| src | ||
| test | ||
| .editorconfig | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| .npmrc | ||
| .nvmrc | ||
| .prettierignore | ||
| .releaserc | ||
| CHANGELOG.md | ||
| CODEOWNERS | ||
| eslint.config.mjs | ||
| example-generator.yaml | ||
| index.ts | ||
| LICENSE | ||
| package-lock.json | ||
| package.json | ||
| prettier.config.mjs | ||
| README.md | ||
| renovate.json | ||
| tsconfig.dist.json | ||
| tsconfig.json | ||
NLdoc Document Specification
An OpenAPI 3.1.0 compatible specification for describing digital documents. This TypeScript library provides a comprehensive schema framework for representing document structure, content, and metadata.
Overview
This specification defines a standardized schema for describing various types of digital documents including:
- Structured content (headings, paragraphs, lists, tables)
- Multimedia elements (images, assets)
- Document metadata and annotations (footnotes, citations)
- Complex document layouts (nested structures, definition lists)
The specification provides a consistent, type-safe way to describe and structure digital documents, enabling better document management, processing, and integration with document processing systems.
Getting Started
Prerequisites
- Node.js >= 22.0.0 < 23.0.0
- npm >= 10.0.0 < 12.0.0
Installation
Install the package via npm:
npm install @nldoc/document-specification
Or using yarn:
yarn add @nldoc/document-specification
Basic Usage
import {
specification,
validExamples,
invalidExamples
} from '@nldoc/document-specification';
// Access the OpenAPI specification
console.log(specification);
// Use valid examples for testing
console.log(validExamples);
// Use invalid examples for validation testing
console.log(invalidExamples);
Accessing the OpenAPI Specification
After building the project, the complete OpenAPI 3.1.0 specification is available at:
# Build the project first
npm run build
# The OpenAPI specification is now available at:
# - public/openapi.json (JSON format)
# - public/index.html (Interactive HTML documentation)
Development
Local Setup
-
Clone the repository:
git clone https://gitlab.com/logius/nldoc/spec/document.git cd document-specification -
Install dependencies:
npm install -
Build the project:
npm run build
Available Scripts
npm run test- Run the test suite with Vitestnpm run build- Build the OpenAPI specification, examples, and TypeScript filesnpm run lint- Lint the codebase using ESLintnpm run format- Format code using Prettiernpm run format:check- Check code formattingnpm run fix- Auto-fix linting and formatting issuesnpm run lint:openapi- Generate an HTML report for the OpenAPI specification
Building Components
The build process consists of several steps:
- OpenAPI Generation:
npm run build:openapi- Generates the OpenAPI JSON specification - Example Extraction:
npm run build:examples- Extracts valid and invalid test examples - TypeScript Compilation: Compiles TypeScript to JavaScript for distribution
- Documentation:
npm run build:redocly- Generates HTML documentation using Redocly
Document Types
The specification supports various document elements:
Core Resources
- Document: The root document container
- Asset: External resources (images, files, etc.)
- Footnote: Document footnotes and references
Text Elements
- Heading: Document headings (H1-H6)
- Paragraph: Text paragraphs with inline content
- Text: Plain text content
- Link: Hyperlinks
Structural Elements
- Table: Tables with headers, rows, and cells
- OrderedList/UnorderedList: Numbered and bulleted lists
- DefinitionList: Term-definition pairs
- BlockQuotation: Quoted content blocks
- Preformatted: Pre-formatted text blocks
Media Elements
- Image: Image resources with metadata
API Documentation
The generated OpenAPI specification can be viewed:
- Locally: After building, open
public/index.htmlin your browser - Online: View the latest release documentation
Testing
Run the test suite:
npm test
Contributing
We welcome contributions! Please ensure:
- All tests pass (
npm test) - Code is properly formatted (
npm run format:check) - Linting rules are followed (
npm run lint) - OpenAPI specification is valid (
npm run lint:openapi)
License
This project is licensed under the European Union Public License 1.2 - see LICENSE for details.
Acknowledgements
- Built on OpenAPI 3.1.0 specification
- Integrates with Schema.org standards
- Uses Redocly for API documentation generation