Skip to content

Latest commit

 

History

History
149 lines (107 loc) · 3.46 KB

sourcemap.md

File metadata and controls

149 lines (107 loc) · 3.46 KB

module sourcemap

sourcemap

Generate source maps.

Installation

v install aheissenberger.sourcemap

Usage

Generator

	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

Consumer

not implemented

API Documentation

auto generated documentation (created v doc -f md -m . -o .)

Roadmap

  • implement consumer
  • performance benchmark
  • rewrite with streaming to IO

Contribution

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.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the "bsd-2-clause" License. See LICENSE.txt for more information.

Contents

generate_empty_map

fn generate_empty_map() &Generator

[Return to contents]

new_sourcemap

fn new_sourcemap(file string, source_root string) SourceMap

[Return to contents]

Generator

add_map

fn (mut g Generator) add_map(file string, source_root string, line_offset int, column_offset int) &SourceMap

[Return to contents]

SourceMap

add_mapping

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.

[Return to contents]

add_mapping_list

fn (mut sm SourceMap) add_mapping_list(source_name string, mapping_list []MappingInput) ?

Add multiple mappings from the same source

[Return to contents]

set_source_content

fn (mut sm SourceMap) set_source_content(source_name string, source_content string)

Set the source content for a source file.

[Return to contents]

to_json

fn (mut sm SourceMap) to_json() SourceMapJson

create a JSON representing the sourcemap Sourcemap Specs http://sourcemaps.info/spec.html

[Return to contents]

SourcePosition

struct SourcePosition {
	source_line   u32
	source_column u32
}

[Return to contents]

Powered by vdoc. Generated on: 7 Jun 2021 23:45:00