Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does it really work ? #85

Open
ZaniaDeveloper opened this issue Aug 11, 2017 · 6 comments
Open

Does it really work ? #85

ZaniaDeveloper opened this issue Aug 11, 2017 · 6 comments

Comments

@ZaniaDeveloper
Copy link

First, Bravo for making this project.

I tried to use it but no result done. So, i looked at the code and in cmd/c6, the function that codes compile command is empty, just create runtime.Context but the result is assigned to the empty variable (_).

Therefore i suppose that cmd/c6 is not the good main package. And the README.md doesn't explain how to make the project.

I saw an Ant project file (build.xml) but again nothing did, an executable go_env doesn't exist. Except cmd/c6, i cannot find any other main package.

How can i build the binary to execute ?

@hashworks
Copy link

hashworks commented Feb 10, 2018

It's really sad that there is absolutely zero useful documentation on a project with 392 stars. Every not-closed issue is from c9s and there are multiple closed issues asking how to use this, without answers.

I tried to work something out from the parser tests:

package main

import (
	"fmt"
	"github.com/c9s/c6/parser"
	"github.com/c9s/c6/runtime"
)

func main() {
	p := parser.NewParser(runtime.NewContext())
	stmtList, err := p.ParseScssFile("main.scss")
	if err != nil {
		fmt.Println(err)
	} else {
		// ?
	}
}

However ParseScssFile returns *ast.StmtList and I have no idea how to use it.

@ZaniaDeveloper
Copy link
Author

ZaniaDeveloper commented Feb 15, 2018

Does someone want to take the follow up ?

@char101
Copy link

char101 commented Feb 18, 2018

package main

import (
	"fmt"
	"github.com/c9s/c6/parser"
	"github.com/c9s/c6/runtime"
	"github.com/c9s/c6/compiler"
)

func main() {
	context := runtime.NewContext()
	parser := parser.NewParser()
	stmts, err := p.ParseScssFile("main.scss")
	if err != nil {
		log.Fatal(err)
	}
	compiler := compiler.NewCompactCompiler(context)
	out := compiler.CompileString(stmts)
	ioutil.WriteFile("main.css", []byte(out), 0644)
}

See https://github.com/c9s/c6/blob/master/compiler/compact_compiler_test.go#L8

@corebreaker
Copy link

@char101 thank you for your example. I modified it to have something which compiles, that gives:

package main

import (
	// "fmt"                                         <--- `fmt` package is not used
	"io/ioutil" //                                   <--- `io/ioutil` package is missing
	"log"       //                                    <--- `log` package is missing

	"github.com/c9s/c6/compiler"
	"github.com/c9s/c6/parser"
	"github.com/c9s/c6/runtime"
)

func main() {
	context := runtime.NewContext()
	// parser := parser.NewParser()                  <--- `parser.NewParser()` method asks `context` argument
	parser := parser.NewParser(context)
	// stmts, err := p.ParseScssFile("main.scss")    <--- I suppose p == parser
	stmts, err := parser.ParseScssFile("main.scss")
	if err != nil {
		log.Fatal(err)
	}
	compiler := compiler.NewCompactCompiler(context)
	out := compiler.CompileString(stmts)
	ioutil.WriteFile("main.css", []byte(out), 0644)
}

Then, i tried the example on this SCSS file:

/*-----------------------------------------
   Colors
  ----------------------------------------- */
$bordercolor: #ccc;
$iconcolor: #6a737b;
$textcolor: #444;
$background: white;
$itembackground: #e6e7e8;

/*-----------------------------------------
   Magic Search bar
  ----------------------------------------- */
.search-bar {
    position: relative;
    border: 1px solid $bordercolor;
    background-color: $background;
    margin-bottom: 0.5rem;
    padding: 0.25rem;
    height: auto;
    i.fi-filter {
        color: $iconcolor;
        position: absolute;
        top: 0.35rem;
        left: 0.65rem;
    }
    .search-main-area {
        position: relative;
        margin-left: 1.65rem;
        margin-right: 1.65rem;
        cursor: text;
    }
    .search-selected {
        position: relative;
        padding-left: 0;
        padding-right: 0;
        background-color: $background;
        color: $textcolor;
    }
    .search-entry {
        position: relative;
        display: inline-block;
        height: 1.5rem;
        height: 1.5rem;
    }
    .search-input {
        width: 17.5rem;
        border: 0;
        box-shadow: none;
        height: 1.5rem;
        padding: 0.25rem;
        margin-bottom: 0;
        background-color: $background;
        &:focus {
            box-shadow: none;
            background-color: $background;
        }
    }
    .match {
        font-weight: bold;
    }
    i.cancel {
        color: $iconcolor;
        &:hover {
            color: darkred;
        }
        position: absolute;
        top: 0.35rem;
        right: 0.65rem;
    }
    .f-dropdown.open {
        left: 0 !important;
    }
}

But the produced file main.css is empty.

@char101
Copy link

char101 commented Mar 6, 2018

Sorry, I didn't tried the code before, I only copy pasted it from the test source code.

I have checked it out and it looks like that this compiler is not ready get. I found at least two problems

  1. it stops when it find a comment node because it does not handle comment type in rules.go#L109
  2. if you remove all comments from the source, it stops with String() not implemented yet error at ruleset.go#L24

Maybe you can use this project instead: go-libass.

@corebreaker
Copy link

corebreaker commented Mar 6, 2018

I think so. What really a pity ! Currently, Libsass is the best alternative.

But a project like c6 should have a good performance improvement compared to Libsass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants