如何写美丽的无礼

The following is a short extract from our book, Jump Start Sass, written by Hugo Giraudel and Miriam Suzanne. It’s the ultimate beginner’s guide to Sass. SitePoint Premium members get access with their membership, or you can buy a copy in stores worldwide.

以下是Hugo Giraudel和Miriam Suzanne所著《 Jump Start Sass 》一书的摘录。 这是Sass的终极入门指南。 SitePoint Premium成员可以使用其成员身份进行访问,或者您可以在世界各地的商店中购买副本。

Clean, beautiful code should be a goal in every project. If other developers need to make a change, they should be able to read what is there and understand it. Readable code is the core of maintainability, and the first step towards readable code is a good linter. Like a good spell-checker, the linter should catch all your small typos and formatting mistakes, so it’s not left to others to do so. It’s the first line of defense before a good code review with other developers.

干净,漂亮的代码应该成为每个项目的目标。 如果其他开发人员需要进行更改,则他们应该能够阅读并理解其中的内容。 可读代码是可维护性的核心,并朝向可读代码的第一个步骤是一个很好的棉绒 。 像一个好的拼写检查器一样,lint应该捕获所有小的拼写错误和格式错误,因此不要让别人这样做。 在与其他开发人员进行良好的代码审查之前,这是第一道防线。

There are several great linters for Sass: scss-lint is a Ruby gem, and the newer sasslint and stylelint, which are npm packages for Node. Both allow you to configure linting rules for your project, such as maximum nesting levels, leading zeros on decimals, and organization of properties in a block. You can even create your own rules as needed.

Sass有很多出色的功能: scss-lint是Ruby宝石,而较新的sasslint和stylelint是Node的npm软件包。 两者都允许您为项目配置起毛规则,例如最大嵌套级别,小数点前的零以及块中的属性组织。 您甚至可以根据需要创建自己的规则。

Sass Guidelines are handy for organizing your project, setting up your linters, establishing naming conventions, and so on. Written by Hugo, it’s an opinionated styleguide for your code; it might not all work for you, but it’s a great place to start.

Sass指南可用于组织项目,设置样机,建立命名约定等。 由Hugo撰写,它是您代码的自以为是的样式指南; 它可能并不全为您服务,但这是一个不错的起点。

If you’re using Sass variables, functions, and mixins, it’s recommended that you document how they work. Toolkit authors will find it particularly important, but anyone who has extensive tooling built into their projects should also consider documentation for their team. Another great tool from Hugo is SassDoc, an npm package that parses your Sass comments and generates a beautiful static site with your documentation.

如果您使用的是Sass变量,函数和混合,建议您记录一下它们的工作方式。 工具包作者会发现它特别重要,但是任何在项目中内置大量工具的人都应该考虑为其团队使用文档。 Hugo的另一个很棒的工具是SassDoc ,这是一个npm软件包,可以解析您的Sass注释并使用您的文档生成漂亮的静态站点。

Here’s the SassDoc comment for our function in Accoutrement-Colors. It starts with a general description, and then explicitly documents each parameter and the expected return:

这是Accoutrement-Colors中我们函数的SassDoc注释。 它以一般描述开始,然后显式记录每个参数和预期的回报:

Using the default theme (from which there are several to choose, or you can design your own), SassDoc converts that comment into a static website, as shown below.

使用默认主题(可以从中选择多个主题,也可以设计自己的主题),SassDoc将该评论转换为静态网站,如下所示。

如何写美丽的无礼

翻译自: https://www.sitepoint.com/writing-beautiful-sass/

文章知识点与官方知识档案匹配,可进一步学习相关知识Java技能树首页概览92531 人正在系统学习中 相关资源:电子礼金簿Ver1.5-管理软件其他资源-CSDN文库

来源:culi3182

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年8月1日
下一篇 2020年8月1日

相关推荐