Skip to content

1-js/03-code-quality/03-comments#37

Merged
leviding merged 4 commits intozh-hansfrom
transfer/comments
Apr 23, 2018
Merged

1-js/03-code-quality/03-comments#37
leviding merged 4 commits intozh-hansfrom
transfer/comments

Conversation

@linhe0x0
Copy link
Copy Markdown

resolve #19

resolve #19
@leviding leviding added the WIP Work in process label Apr 12, 2018
@linhe0x0 linhe0x0 self-assigned this Apr 12, 2018
@linhe0x0 linhe0x0 changed the title [WIP] 1-js/03-code-quality/03-comments 1-js/03-code-quality/03-comments Apr 12, 2018
@linhe0x0 linhe0x0 removed the WIP Work in process label Apr 12, 2018
@Starriers
Copy link
Copy Markdown
Contributor

校对认领

Copy link
Copy Markdown
Contributor

@Starriers Starriers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sqrthree @leviding 校对完成

# 注释

As we know from the chapter <info:structure>, comments can be single-line: starting with `//` and multiline: `/* ... */`.
正如我们在 <info:structure> 这一章所了解到的那样,注释可以是以 `//` 开始的单行注释,或是 `/* ... */` 结构的多行注释。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 是不是多了一个空格

从第一眼看,注释代表的东西可能是显而易见的,但编程中的新手通常会弄错。

## Bad comments
## 坏注释
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

坏 =》 糟糕的

- 只有在没有这些就不可能使代码变得如此简单和自我描述的情况下才可以使用它们。

Comments are also used for auto-documenting tools like JSDoc3: they read them and generate HTML-docs (or docs in another format).
注释也被用于一些自动文档工具:他们读取注释然后构建出 HTML 文档(或者其他格式)。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在工具后加上 (比如 JSDoc3)
或者其他格式 =》或者其他格式的文档。

发现译者翻译喜欢省略内容,改原文格式。意译的时候一些重要的信息还是保留比较好,比较它们存在都是有原因的。

- Important solutions, especially when not immediately obvious.
- 整体架构,高层次的观点。
- 函数的用法。
- 重要的解决方案,特别是当不是很明显时。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当 =》 在

```

Now we can understand the code easily. The function itself becomes the comment. Such code is called *self-descriptive*.
现在我们可以很容易的理解代码了。函数自己变成了注释。这种代码被称之为“自我描述型”代码。
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“” =》 **** 改为加粗

Signed-off-by: sqrtthree <imsqrtthree@gmail.com>
@linhe0x0
Copy link
Copy Markdown
Author

感谢建议,已调整。

Why is the task solved this way?
: What's written is important. But what's *not* written may be even more important to understand what's going on. Why is the task solved exactly this way? The code gives no answer.
为什么任务以这种方式解决?
: 写了什么代码很重要。但是什么代码**不**写对于理解发生了什么或许更重要。为什么任务恰好用这种方式解决了?代码并没有给出答案。
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

开头的冒号和空格应该用一个中文冒号替代?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

网站上把这段渲染成了标题和段落,并自动删除了 :,换成全角的会出现问题吧。
image

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

喔喔,明白了

@leviding leviding merged commit f53a1fc into zh-hans Apr 23, 2018
@leviding leviding deleted the transfer/comments branch April 23, 2018 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants