Skip to content

Commit bb090ed

Browse files
committed
Merge pull request #1234 from drewwells/feature/md
Convert wiki to markdown
2 parents e075dcb + cd29efa commit bb090ed

33 files changed

+3554
-0
lines changed

docs/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Welcome to the LibSass wiki!
2+
3+
## First Off
4+
LibSass is just a library. To run the code locally (i.e. to compile your stylesheets), you need an implementer. SassC (get it?) is an implementer written in C. There are a number of other implementations of LibSass - for example Node. We encourage you to write your own port - the whole point of LibSass is that we want to bring Sass to many other languages, not just Ruby!
5+
6+
We're working hard on moving to full parity with Ruby Sass... learn more at the [The-LibSass-Compatibility-Plan](compatibility-plan.md)!
7+
8+
### Implementing LibSass
9+
10+
If you're interested in implementing LibSass in your own project see the [API Documentation](api-doc.md) which now includes implementing
11+
your own [Sass functions](api-function.md). You may wish to [look at other implementations](implementations.md) for your language of choice.
12+
Or make your own!
13+
14+
### Contributing to LibSass
15+
16+
| Issue Tracker | Issue Triage | Community Guidelines |
17+
|-------------------|----------------------------------|-----------------------------|
18+
| We're always needing help, so check out our issue tracker, help some people out, and read our article on [Contributing](contributing.md)! It's got all the details on what to do! | To help understand the process of triaging bugs, have a look at our [Issue-Triage](triage.md) document. | Oh, and don't forget we always follow [[Sass Community Guidelines|http://sass-lang.com/community-guidelines]]. Be nice and everyone else will be nice too! |
19+
20+
Please refer to the steps on [Building LibSass](build.md)

docs/api-context-example.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Example main.c
2+
3+
```C
4+
#include <stdio.h>
5+
#include "sass_context.h"
6+
7+
int main( int argc, const char* argv[] )
8+
{
9+
10+
// get the input file from first argument or use default
11+
const char* input = argc > 1 ? argv[1] : "styles.scss";
12+
13+
// create the file context and get all related structs
14+
struct Sass_File_Context* file_ctx = sass_make_file_context(input);
15+
struct Sass_Context* ctx = sass_file_context_get_context(file_ctx);
16+
struct Sass_Options* ctx_opt = sass_context_get_options(ctx);
17+
18+
// configure some options ...
19+
sass_option_set_precision(ctx_opt, 10);
20+
21+
// context is set up, call the compile step now
22+
int status = sass_compile_file_context(file_ctx);
23+
24+
// print the result or the error to the stdout
25+
if (status == 0) puts(sass_context_get_output_string(ctx));
26+
else puts(sass_context_get_error_message(ctx));
27+
28+
// release allocated memory
29+
sass_delete_file_context(file_ctx);
30+
31+
// exit status
32+
return status;
33+
34+
}
35+
```
36+
37+
### Compile main.c
38+
39+
```bash
40+
gcc -c main.c -o main.o
41+
gcc -o sample main.o -lsass
42+
echo "foo { margin: 21px * 2; }" > foo.scss
43+
./sample foo.scss => "foo { margin: 42px }"
44+
```
45+

docs/api-context-internal.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
```C
2+
// Input behaviours
3+
enum Sass_Input_Style {
4+
SASS_CONTEXT_NULL,
5+
SASS_CONTEXT_FILE,
6+
SASS_CONTEXT_DATA,
7+
SASS_CONTEXT_FOLDER
8+
};
9+
10+
// simple linked list
11+
struct string_list {
12+
string_list* next;
13+
char* string;
14+
};
15+
16+
// sass config options structure
17+
struct Sass_Options {
18+
19+
// Precision for fractional numbers
20+
int precision;
21+
22+
// Output style for the generated css code
23+
// A value from above SASS_STYLE_* constants
24+
enum Sass_Output_Style output_style;
25+
26+
// Emit comments in the generated CSS indicating
27+
// the corresponding source line.
28+
bool source_comments;
29+
30+
// embed sourceMappingUrl as data uri
31+
bool source_map_embed;
32+
33+
// embed include contents in maps
34+
bool source_map_contents;
35+
36+
// Disable sourceMappingUrl in css output
37+
bool omit_source_map_url;
38+
39+
// Treat source_string as sass (as opposed to scss)
40+
bool is_indented_syntax_src;
41+
42+
// The input path is used for source map
43+
// generation. It can be used to define
44+
// something with string compilation or to
45+
// overload the input file path. It is
46+
// set to "stdin" for data contexts and
47+
// to the input file on file contexts.
48+
char* input_path;
49+
50+
// The output path is used for source map
51+
// generation. LibSass will not write to
52+
// this file, it is just used to create
53+
// information in source-maps etc.
54+
char* output_path;
55+
56+
// String to be used for indentation
57+
const char* indent;
58+
// String to be used to for line feeds
59+
const char* linefeed;
60+
61+
// Colon-separated list of paths
62+
// Semicolon-separated on Windows
63+
// Note: It may be better to use
64+
// array interface instead
65+
char* include_path;
66+
char* plugin_path;
67+
68+
// Include paths (linked string list)
69+
struct string_list* include_paths;
70+
// Plugin paths (linked string list)
71+
struct string_list* plugin_paths;
72+
73+
// Path to source map file
74+
// Enables source map generation
75+
// Used to create sourceMappingUrl
76+
char* source_map_file;
77+
78+
// Directly inserted in source maps
79+
char* source_map_root;
80+
81+
// Custom functions that can be called from sccs code
82+
Sass_C_Function_List c_functions;
83+
84+
// Callback to overload imports
85+
Sass_C_Import_Callback importer;
86+
87+
};
88+
89+
// base for all contexts
90+
struct Sass_Context : Sass_Options
91+
{
92+
93+
// store context type info
94+
enum Sass_Input_Style type;
95+
96+
// generated output data
97+
char* output_string;
98+
99+
// generated source map json
100+
char* source_map_string;
101+
102+
// error status
103+
int error_status;
104+
char* error_json;
105+
char* error_text;
106+
char* error_message;
107+
// error position
108+
char* error_file;
109+
size_t error_line;
110+
size_t error_column;
111+
112+
// report imported files
113+
char** included_files;
114+
115+
};
116+
117+
// struct for file compilation
118+
struct Sass_File_Context : Sass_Context {
119+
120+
// no additional fields required
121+
// input_path is already on options
122+
123+
};
124+
125+
// struct for data compilation
126+
struct Sass_Data_Context : Sass_Context {
127+
128+
// provided source string
129+
char* source_string;
130+
131+
};
132+
133+
// Compiler states
134+
enum Sass_Compiler_State {
135+
SASS_COMPILER_CREATED,
136+
SASS_COMPILER_PARSED,
137+
SASS_COMPILER_EXECUTED
138+
};
139+
140+
// link c and cpp context
141+
struct Sass_Compiler {
142+
// progress status
143+
Sass_Compiler_State state;
144+
// original c context
145+
Sass_Context* c_ctx;
146+
// Sass::Context
147+
void* cpp_ctx;
148+
// Sass::Block
149+
void* root;
150+
};
151+
```
152+

0 commit comments

Comments
 (0)