Generate source maps.
v install aheissenberger.sourcemap
mut sg := generate_empty_map() or { panic('broken') }
mut sm := sg.add_map('hello.js', '/', 0, 0)
sm.add_mapping('hello.v', SourcePosition{
source_line: 0
source_column: 0
}, 1, 1, '')
sm.add_mapping('hello_lib1.v', SourcePosition{
source_line: 0
source_column: 0
}, 2, 1, '')
sm.add_mapping('hello_lib2.v', SourcePosition{
source_line: 0
source_column: 0
}, 3, 1, '')
json_data := sm.to_json()
expected := '{"version":3,"file":"hello.js","sourceRoot":"\\/","sources":["hello.v","hello_lib1.v","hello_lib2.v"],"sourcesContent":[null,null,null],"names":[],"mappings":"CA+\\/\\/\\/\\/\\/HA;CCAA;CCAA"}'
assert json_data.str() == expected
not implemented
auto generated documentation
(created v doc -f md -m . -o .
)
- implement consumer
- performance benchmark
- rewrite with streaming to IO
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request
Distributed under the "bsd-2-clause" License. See LICENSE.txt for more information.
fn generate_empty_map() &Generator
fn new_sourcemap(file string, source_root string) SourceMap
fn (mut g Generator) add_map(file string, source_root string, line_offset int, column_offset int) &SourceMap
fn (mut sm SourceMap) add_mapping(source_name string, source_position SourcePositionType, gen_line u32, gen_column u32, name string)
Add a single mapping from original source line and column to the generated source's line and column for this source map being created.
fn (mut sm SourceMap) add_mapping_list(source_name string, mapping_list []MappingInput) ?
Add multiple mappings from the same source
fn (mut sm SourceMap) set_source_content(source_name string, source_content string)
Set the source content for a source file.
fn (mut sm SourceMap) to_json() SourceMapJson
create a JSON representing the sourcemap Sourcemap Specs http://sourcemaps.info/spec.html
struct SourcePosition {
source_line u32
source_column u32
}