web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
5.3 KiB

  1. # Contributing
  2. ## Contributor License Agreement
  3. In order to contribute, you must accept the [contributor license agreement](https://cla-assistant.io/dequelabs/axe-core) (CLA). Acceptance of this agreement will be checked automatically and pull requests without a CLA cannot be merged.
  4. ## Contribution Guidelines
  5. Submitting code to the project? Please review and follow our
  6. [Git commit and pull request guidelines](doc/code-submission-guidelines.md).
  7. ### Code Quality
  8. Although we do not have official code style guidelines, we can and will request you to make changes
  9. if we think that your code is sloppy. You can take clues from the existing code base to see what we
  10. consider to be reasonable code quality. Please be prepared to make changes that we ask of you even
  11. if you might not agree with the request(s).
  12. Please respect the coding style of the files you are changing and adhere to that.
  13. The JavaScript files in this project are formatted by [Prettier](https://prettier.io/). Additionally, we prefer:
  14. 1. Tabs over spaces
  15. 2. Single quotes for string literals
  16. 3. Function definitions like `function functionName(arguments) {`
  17. 4. Variable function definitions like `Class.prototype.functionName = function (arguments) {`
  18. 5. Use of 'use strict'
  19. 6. Variables declared at the top of functions
  20. ### Shadow DOM
  21. For any proposed changes to rules, checks, commons, or other APIs to be accepted
  22. in axe-core, your code must support open Shadow DOM. See [API.md](./doc/API.md) and the
  23. [developer guide](./doc/developer-guide.md) for documentation on the available methods
  24. and test utilities. You can also look at existing tests for examples using our APIs.
  25. ### Testing
  26. We expect all code to be 100% covered by tests. We don't have or want code coverage metrics but we will review tests and suggest changes when we think the test(s) do(es) not adequately exercise the code/code changes.
  27. ### Documentation and Comments
  28. Functions should contain a preceding comment block with [jsdoc](http://usejsdoc.org/) style documentation of the function. For example:
  29. ```js
  30. /**
  31. * Runs the Audit; which in turn should call `run` on each rule.
  32. * @async
  33. * @param {Context} context The scope definition/context for analysis (include/exclude)
  34. * @param {Object} options Options object to pass into rules and/or disable rules or checks
  35. * @param {Function} fn Callback function to fire when audit is complete
  36. */
  37. ```
  38. Classes should contain a jsdoc comment block for each attribute. For example:
  39. ```js
  40. /**
  41. * Constructor for the result of checks
  42. * @param {Object} check CheckResult specification
  43. */
  44. function CheckResult(check) {
  45. 'use strict';
  46. /**
  47. * ID of the check. Unique in the context of a rule.
  48. * @type {String}
  49. */
  50. this.id = check.id;
  51. /**
  52. * Any data passed by Check (by calling `this.data()`)
  53. * @type {Mixed}
  54. */
  55. this.data = null;
  56. /**
  57. * Any node that is related to the Check, specified by calling `this.relatedNodes([HTMLElement...])` inside the Check
  58. * @type {Array}
  59. */
  60. this.relatedNodes = [];
  61. /**
  62. * The return value of the Check's evaluate function
  63. * @type {Mixed}
  64. */
  65. this.result = null;
  66. }
  67. ```
  68. ## Setting up your environment
  69. In order to get going, fork and clone the repository. Then, if you do not have [Node.js](https://nodejs.org/download/) installed, install it!
  70. Once the basic infrastructure is installed, from the repository root, do the following:
  71. ```console
  72. npm install
  73. ```
  74. To run tests:
  75. ```console
  76. grunt test
  77. ```
  78. To build the package:
  79. ```console
  80. grunt build
  81. ```
  82. ## Using axe with TypeScript
  83. ### Axe Development
  84. The TypeScript definition file for axe-core is distributed with this module and can be found in [axe.d.ts](./axe.d.ts). It currently supports TypeScript 2.0+.
  85. To maintain axe support for TypeScript you must first install it (globally recommended):
  86. ```console
  87. sudo npm -g install typescript
  88. ```
  89. Once that's installed, you can run TypeScript definition tests (with the optional `--noImplicitAny` flag):
  90. ```console
  91. tsc --noImplicitAny typings/axe-core/axe-core-tests.ts
  92. ```
  93. ## Including axe's type definition in tests
  94. Installing axe to run accessibility tests in your TypeScript project should be as simple as importing the module:
  95. ```js
  96. import * as axe from 'axe-core';
  97. describe('Module', () => {
  98. it('should have no accessibility violations', done => {
  99. axe.run(compiledFixture).then(results => {
  100. expect(results.violations.length).toBe(0);
  101. done();
  102. }, done);
  103. });
  104. });
  105. ```
  106. ## Debugging tests that only fail on CircleCI
  107. First install an X-Windows client on your machine. XQuartz is a good one.
  108. Then follow the [instructions here to connect the X-Windows on CircleCI to XQuartz](https://circleci.com/docs/1.0/browser-debugging/#x11-forwarding-over-ssh)
  109. Start the build using the "Retry the build with SSH enabled" option in the CircleCI interface
  110. Copy the SSH command and add the -X flag to it for example
  111. ```console
  112. ssh -X -p 64605 ubuntu@13.58.157.61
  113. ```
  114. When you login, set up the environment and start the chrome browser
  115. ```console
  116. export DISPLAY=localhost:10.0
  117. /opt/google/chrome/chrome
  118. ```
  119. ### .Xauthority does not exist
  120. Edit the ~/.Xauthority file and just save it with the following commands
  121. ```console
  122. vi ~/.Xauthority
  123. :wq
  124. ```
  125. ### Starting the web server
  126. Log into a second ssh terminal (without -X) and execute the following commands
  127. ```console
  128. cd axe-core
  129. grunt connect watch
  130. ```
  131. Load your test file URL in the Chrome browser opened in XQuartz