c6 icon indicating copy to clipboard operation
c6 copied to clipboard

Does it really work ?

Open ZaniaDeveloper opened this issue 8 years ago • 6 comments

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 ?

ZaniaDeveloper avatar Aug 11 '17 11:08 ZaniaDeveloper

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.

hashworks avatar Feb 10 '18 17:02 hashworks

Does someone want to take the follow up ?

ZaniaDeveloper avatar Feb 15 '18 17:02 ZaniaDeveloper

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

char101 avatar Feb 18 '18 05:02 char101

@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.

corebreaker avatar Mar 05 '18 14:03 corebreaker

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.

char101 avatar Mar 06 '18 10:03 char101

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.

corebreaker avatar Mar 06 '18 11:03 corebreaker