WebRTC GitHub repo developer's guide

https://github.com/LingyuCoder/SkyRTC-demo



WebRTC GitHub repo developer's guide

Validation

Project structure and style

JavaScript quirks

Working with GitHub

Pull request won’t merge automatically?

GitHub Pages

Unwanted commits in pull request?

Bower

Validation with Grunt plugins and Travis

Grunt

Travis

The repo is at github.com/webrtc and the samples can be viewed live at webrtc.github.io/samples.

Before contributing code, please check the CONTRIBUTING file.

Validation

HTML, CSS and JavaScript should follow the Google style guide.

All JavaScript must pass ESLint validation and follow the options in samples/.eslintrc. ESLint plugins are available for Sublime and other editors, and ESLint validation can be run as a Grunt task. If necessary (rarely), include additional ESLint directives within individual JavaScript files.

All JavaScript files must have 'use strict'; at the top, to invoke global strict mode.

All HTML must pass HTMLHint checking. Likewise, CSSLint must not find errors (though some warnings are acceptable).

The W3C validators for CSS and HTML are also useful.

Project structure and style

For each new code sample, create a new directory in the appropriate subdirectory of  src/content.

Put JavaScript in a separate file. Each demo should have a directory structure like this:

index.html

/js/main.js

If your CSS has more than about five rules, put it in a separate file:

/css/main.css

Declare all global variables and element variables at the top of main.js.

Put all conditional statements in a block, even if only one line.

By default use === and !== for testing equality. This makes equality testing explicit, without coercion.

Put a semicolon at the end of every statement. This is easy to forget with handlers, for example:

stream.onFoo = function(){...}; // this is a statement

Prefer [] to new Array(), for example:

var myArray = [];

Prefer dot nation. For example use this:

pcConfig.iceServers[i].url

...instead of this:

pcConfig.iceServers[i]['url'];

Double quote string values in HTML, single quote in JavaScript (as per Google style guide).

Variables are camelCase. In general, don't use hyphens in names.

Indent with two spaces. When function calls or tests run onto multiple lines, indent with four spaces:

var iceServers = createIceServers(turnServer.uris,

turnServer.username, turnServer.password);

alert('Failed to create data channel. ' +

'You need Chrome 25 or later with --enable-data-channels flag');

if (sctpSelect.checked &&
   (detectedBrowser === 'chrome' && detectedVersion >= 31) ||

detectedBrowser === 'firefox') {

...

}

JavaScript quirks

Watch out not to miss the var keyword in variable declarations: variables used in a function without var are in global scope.

To put a variable in global scope, make it explicit by qualifying the name with window, for example:

var video = window.video = document.querySelector(‘video’);

function successCallback(stream) {

window.stream = stream; // stream available to console
 ...

}

Likewise, be explicit when referring to objects belonging to window, for example window.performance.

Working with GitHub

For minor code changes, fork the repo and make a pull request from your GitHub account.

For major/ongoing changes, create a branch and issue pull requests from that. Please delete the branch once you’ve finished working on it.

Once a pull request has been generated the assigned reviewer should merge it to master once all the comments have been addressed.

Git log not clear enough to interpret? Try git log --graph --decorate --oneline

Squash commits? Here is how.

This page has a useful flowchart for getting out of Git tangles. Here is another page.

All events for the repo can be viewed at api.github.com/repos/GoogleChrome/webrtc/events. This includes items that may not show up in the commits log.

Pull request won’t merge automatically?

  1. git pull master

  2. Check out branch

  3. git merge master

  4. Edit the merge conflict

  5. git add <changed files>

  6. git commit -am 'merge master'

  7. git push

GitHub Pages

When you make a pull request, please include links to updated samples running on GitHub Pages on your repo. For example: samdutton.github.io/webrtc/src/content/getusermedia/gum. This enables reviewers to check functionality without needing to pull your branch and run the changes locally.

Unwanted commits in pull request?

  1. Checkout the branch in question

  2. git rebase -i “SHA1 of the commit you do not want to see”

    1. squash all commits except the topmost one (assuming it’s the commit from step 2)

  3. Fix all the conflicts if any

    1. fix conflict

    2. git add filename

    3. git rebase --continue

    4. Rinse and repeat until done

    5. Note: Make sure to just leave the commit message you want in the end f

  4. git push --force origin <branch>

Note: You effectively lose commit history by doing this as you change the reference commit.

Bower

sudo npm install bower

Dependency version handing: https://github.com/npm/node-semver

Run bower update in the root folder of the project or sub project (e.g. testrtc), usually if a folder contains a bower.json file it’s considered root.

Validation with Grunt plugins and Travis

This project has been set up to enable automated testing with Grunt plugins and Travis.

Grunt

Grunt uses Node.js to automate tasks written in JavaScript. Two files in a project’s top level code directory provide information for Grunt to be used with that project:

  • package.json describes dependencies and other project data.

  • Gruntfile.js defines options for the tasks which can be run with Grunt for the project.

    For example, the Gruntfile for the WebRTC sample repo gives options for three Grunt plugins: CSSLint, HTMLHint, ESLint. These are predefined tasks used to validate code and check coding style. It’s also possible to write your own custom tasks using JavaScript – for unit testing, for example.

    The grunt command can be called with or without parameters, depending on settings defined in the project’s Gruntfile. For example, with the WebRTC sample repo, grunt htmlhint will run the HTMLHint Grunt plugin. Calling grunt on its own runs all the tasks defined by the grunt.registerTask() method in the Gruntfile.js:

    grunt.registerTask('default',
     ['csslint', 'htmlhint', 'eslint']);

The grunt-eslint documentation has simple instructions on how to set up Grunt with ESlint: other plugins are installed in the same way. The Grunt plugins page has more information about popular plugins. Options for Grunt plugins can generally be defined in a project’s Gruntfile as well as in config files (such as .eslintrc and .csslintrc).

Travis

Once a GitHub project has been configured on the Travis website, the Travis server can hook into the GitHub API to respond to events for that project. For example, the public project travis-ci.org/GoogleChrome/webrtc corresponds to the GitHub project github.com/GoogleChrome/webrtc. (Travis can also be used with private projects.)

Once Travis has been given access to the GitHub API for a project, GitHub push or pull events trigger testing (and potentially other build steps) to be done by the Travis server. Whenever the WebRTC samples project is pushed or pulled, the Travis server runs the following steps (this build log gives more detail):

  1. Install and test Node dependencies as defined by package.json in the project’s top level directory.

  2. Call the command defined by the scripts.test property in package.json, which for this project is as follows:

    "scripts": {

"test": "grunt --verbose"

}

As described above, calling the grunt command on its own for this project will run three tasks as defined in Gruntfile.js: CSSLint, HTMLHint and ESLint.

  1. Once all tests have been completed, Travis reports success or failure. Travis can be configured to provide various types of notification. Currently this project is set to send an email to the project owner (dutton@google.com). Travis also updates a project status icon which can be included in documentation on GitHub:

    ![Travis](https://travis-ci.org/webrtc/samples.svg?branch=master)

The travis.yml file at the project’s top level directory defines the language environment, which in this case is Node.js, and can be used for other settings.

Travis can also be used to automate build tasks, though this is not currently used by the WebRTC samples project.

WebRTC GitHub repo developer's guide的更多相关文章

  1. Github Coding Developer Book For LiuGuiLinAndroid

    Github Coding Developer Book For LiuGuiLinAndroid 收集了这么多开源的PDF,也许会帮到一些人,现在里面的书籍还不是很多,我也在一点点的上传,才上传不到 ...

  2. 【Py-Github】根据条件筛选Github repo的例子

    条件: language:python commits:>100 contributors:>2 stars:>5 fork:0 实现: from github import Git ...

  3. 互联网公司GitHub repo 语言使用情况

    转自: https://laike9m.com/blog/hu-lian-wang-gong-si-github-repo-yu-yan-shi-yong-qing-kuang,56/ 现在基本上所有 ...

  4. 【github repo自荐】码农周刊一周精选分类

    以下内容节选自我的github码农周刊整理repo,欢迎大家star. 写在最前面的话 作为最初的一批码农周刊的订阅者,不能说经历了其成长,但是确实见证了他的壮大.码农周刊确实从开始第一期的基本上都是 ...

  5. GitHub Student Developer Pack创建个人网站

    链接:https://zhuanlan.zhihu.com/p/20531579 这个开发包里有什么?作为学生开发者,如何最大化利用它的价值? Atom编辑器,GitHub推出的编辑器,和Sublim ...

  6. Prism5.0开发人员指南内容 Contents of the Developer's Guide to Prism Library 5.0 for WPF(英汉对照版)

    The Prism for WPF guide contains the following topics: Prism指南包含以下内容: Download and Setup Prism 下载并安装 ...

  7. Prism开发人员指南5-WPF开发 Developer's Guide to Microsoft Prism Library 5.0 for WPF (英汉对照版)

    April 2014 2014四月   Prism provides guidance in the form of samples and documentation that help you e ...

  8. 一个用JavaScript生成思维导图(mindmap)的github repo

    github 地址:https://github.com/dundalek/markmap 作者的readme写得很简单. 今天有同事问作者提供的例子到底怎么跑.这里我就写一个更详细的步骤出来. 首先 ...

  9. Java Developer's Guide to SSL Certificates

    https://www.codebyamir.com/blog/java-developers-guide-to-ssl-certificates Overview When developing w ...

随机推荐

  1. 【spring cloud】spring cloud服务发现注解之@EnableDiscoveryClient与@EnableEurekaClient

    spring cloud服务发现注解之@EnableDiscoveryClient与@EnableEurekaClient的区别

  2. 手动安装pip

    apt-get instal pip  成功之后,有根据pip的提示,进行了升级,升级之后,pip就出问题了 为了解决上面问题,手动安装pip,依次执行下面命令 1 2 3 4 5 [root@min ...

  3. sql server 2008出现远程过程调用失败

    sql server  2008出现远程过程调用失败解决方式有下面几种: 1.依照网上说的方法.是由于装了vs 2012或是vs2013或是vs2015等高版本号时.安装了Microsoft SQL ...

  4. Windows下编程2----- C语言常用函数举例

    几个小函数 1.    //MessageBoxA(0,"网络故障,重新登录","qq error",3); //弹出对话框 2.    //ShellExec ...

  5. HAProxy简单使用

    一.HAProxy简介及定位         HAProxy 是一款基于TCP和HTTP应用的具备高可用行且负载均衡的代理软件.HAProxy是完全免费的,借助HAProxy可以快速.可靠地提供基于T ...

  6. wdcp新开站点或绑定域名打不开或无法访问的问题

    一 用IP可以打开,但用域名打开网站显示到默认页面1  站点列表里是否有相应的网站信息 2  检查有没站点配置文件后台 >系统管理 >文件管理器 >虚拟主机站点文件(nginx,ap ...

  7. javascript 高级编程系列 - 函数

    一.函数创建 1. 函数声明 (出现在全局作用域,或局部作用域) function add (a, b) { return a + b; } function add(a, b) { return a ...

  8. centos7下MySQL的配置

    1. 下载mysql的repo源 wget http:.noarch.rpm 2. 安装mysql-community-release-el7-5.noarch.rpm包 rpm .noarch.rp ...

  9. kubectl技巧之查看资源列表,资源版本和资源schema配置

    系列目录 在kubernetes里,pod,service,rs,rc,deploy,resource等对象都需要使用yaml文件来创建,很多时候我们都是参照照官方示例或者一些第三方示例来编写yaml ...

  10. OSEck中odo_vect2pcb的作用

    在基于OSEck RTOS的TI DSP中,中断能够作为一个进程存在,在OSEck系统中,进程分为两类:优先级进程,中断进程. 当可屏蔽中断(INT4~15)发生后,就会运行相应的中断vector,在 ...