我创建了一个使用setuptools的演示项目,它具有以下结构:
project/
|- pizza/
| |- __init__.py
| `- margherita.py
|
|- README.rst
|- setup.cfg
`- setup.py
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用Sphinx自动生成此项目的文档.到目前为止,我已经尝试过:
# Generate a sphinx template
sphinx-quickstart
# Use default settings, except for project name, etc.
sphinx-apidoc -o source .
./setup.py build_sphinx
Run Code Online (Sandbox Code Playgroud)
我觉得必须有到自动生成使用本文档更简单的方法README
,setup.py
和文档字符串.
最后,我想为另一个使用Python C-api的项目自动生成apidocs.我找不到任何东西.
我的主要问题是:是否有更简单的方法来自动生成此文档?
我试图模仿AngularJS中的文件输入上的单击事件.我见过工作jQuery示例,但我不想使用jQuery.
'use strict';
angular.module('MyApp', []).
controller('MyCtrl', function($scope) {
$scope.click = function() {
setTimeout(function() {
var element = angular.element(document.getElementById('input'));
element.triggerHandler('click');
$scope.clicked = true;
}, 0);
};
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://code.angularjs.org/1.3.14/angular.js"></script>
<div ng-app="MyApp" ng-controller="MyCtrl">
<input id="input" type="file"/>
<button ng-click="click()">Click me!</button>
<div ng-if="clicked">Clicked</div>
</div>
Run Code Online (Sandbox Code Playgroud)
注意:由于某种原因,需要按两次按钮才能触发超时功能.
我正在使用setTimeout
因为这篇文章.
如何使用AngularJS/vanilla JavaScript以编程方式单击文件输入?
我目前正在使用gulp任务来测试项目.这使用以下工具运行任务:
gulp-eslint
)gulp-htmlhint
)gulp-postcss
)如果任何这些任务失败,任务将失败.
所有这些工具都具有完美的cli接口.所以我决定使用npm测试脚本来运行这些工具.
简单地说,只需在没有任何标志的情况下调用它们就可以运行所有工具.然后可以使用以下方法完成:
{
...
"scripts": {
"test": "karma && protractor && eslint && htmlhint && stylelint"
},
...
}
Run Code Online (Sandbox Code Playgroud)
但是,这意味着如果karma
失败,其他任何工具都不会运行.
是否可以创建一个所有这些工具都可以运行的设置,但是npm test
如果任何命令失败都会失败?
我有一个相当简单的单声道存储库。它可以在 GitLab\n 上找到。这使用了纱线工作区、TypeScript、Jest、ts-jest
\n和 ESLint 以及eslint-plugin-import
.
我正在尝试使用 TypeScript 正确构建项目包。以前我只是将 TypeScript 文件与 JavaScript 代码一起发布在同一目录中。
\n\n我尝试构建项目可以在 GitLab 合并请求中找到\n此处
\n\n现在存储库遵循以下布局:
\n\n |- example/\n | |- index.ts\n | |- package.json\n | `- tsconfig.json\n |- packages/\n | |- koas-core/\n | | |- src/\n | | | `- index.ts\n | | |- package.json\n | | `- tsconfig.json\n | |- koas-status-code/\n | | |- src/\n | | | `- index.ts\n | | |- package.json\n | | `- tsconfig.json\n …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用本指南在(X)ubuntu 13.04 64位中安装Oracle数据库.一切顺利,直到我进入下一步:
$ sudo /etc/init.d/oracle-xe configure
Oracle Database 11g Express Edition Configuration
-------------------------------------------------
This will configure on-boot properties of Oracle Database 11g Express
Edition. The following questions will determine whether the database should
be starting upon system boot, the ports it will use, and the passwords that
will be used for database accounts. Press <Enter> to accept the defaults.
Ctrl-C will abort.
Specify the HTTP port that will be used for Oracle Application Express [8080]:
Specify a …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使项目依赖于git依赖项.但是,我似乎无法让它发挥作用.我基本上想要实现的是以下内容,但它不起作用:
#!/usr/bin/env python3
from setuptools import setup
setup(
name='spam',
version='0.0.0',
install_requires=[
'git+https://github.com/remcohaszing/pywakeonlan.git'
])
Run Code Online (Sandbox Code Playgroud)
我在上面尝试了几种变体,例如添加@master
或#egg=wakeonlan-0.2.2
,但这没有什么区别.
以下工作,但仅在使用deprecated pip
标志时,--process-dependency-links
:
#!/usr/bin/env python3
from setuptools import setup
setup(
name='spam',
version='0.0.0',
install_requires=[
'wakeonlan'
],
dependency_links=[
'git+https://github.com/remcohaszing/pywakeonlan.git#egg=wakeonlan-0.2.2'
])
Run Code Online (Sandbox Code Playgroud)
这输出:
$ pip install --no-index -e . --process-dependency-links
Obtaining file:///home/remco/Downloads/spam
DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release.
Collecting wakeonlan (from spam==0.0.0)
Cloning https://github.com/remcohaszing/pywakeonlan.git to /tmp/pip-build-mkhpjcjf/wakeonlan
DEPRECATION: Dependency Links processing has been deprecated and will …
Run Code Online (Sandbox Code Playgroud) 我已经创建了一个完全正常的指令.现在撞击后angular
到1.5.0
,我想这指令是什么可以使用新编写一个典型的例子.component()
符号.
出于某种原因,该require
物业似乎不再起作用.
以下是一个简化示例:
angular.module('myApp', [])
.component('mirror', {
template: '<p>{{$ctrl.modelValue}}</p>',
require: ['ngModel'],
controller: function() {
var vm = this;
var ngModel = vm.ngModel;
ngModel.$viewChangeListeners.push(onChange);
ngModel.$render = onChange;
function onChange() {
vm.modelValue = ngModel.$modelValue;
}
}
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
<div ng-app="myApp">
<input ng-model="someModel"/>
<mirror ng-model="someModel"></mirror>
</div>
Run Code Online (Sandbox Code Playgroud)
我也试过require
用作简单的字符串:
...
require: 'ngModel'
...
Run Code Online (Sandbox Code Playgroud)
并作为一个对象:
...
require: {
ngModel: 'ngModel'
}
...
Run Code Online (Sandbox Code Playgroud)
我看过$ compile和component的文档,但我似乎无法让它工作.
如何在AngularJS 1.5组件中需要其他指令控制器?
在我的 Dockerfile 中使用时出现错误COPY --from=reference
。我创建了一个最小的例子:
FROM alpine AS build
FROM scratch
COPY --from=build / /
Run Code Online (Sandbox Code Playgroud)
这会导致以下构建输出:
$ docker build .
Sending build context to Docker daemon 2.048kB
Step 1/3 : FROM alpine AS build
---> b7b28af77ffe
Step 2/3 : FROM scratch
--->
Step 3/3 : COPY --from=build / /
failed to copy files: failed to copy directory: Error processing tar file(exit status 1): Container ID 165578 cannot be mapped to a host ID
Run Code Online (Sandbox Code Playgroud)
构建在 CI 中运行良好,但在运行 Ubuntu 18:04 的笔记本电脑上失败。什么可能导致此问题?
我在 JavaScript 中经常使用 async/await。现在我\xe2\x80\x99m逐渐将我的代码库的某些部分转换为TypeScript。
\n\n在某些情况下,我的函数接受将被调用和等待的函数。这意味着它可以返回一个承诺,只是一个同步值。我已经Awaitable
为此定义了类型。
type Awaitable<T> = T | Promise<T>;\n\nasync function increment(getNumber: () => Awaitable<number>): Promise<number> {\n const num = await getNumber();\n return num + 1;\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n可以这样调用:
\n\n// logs 43\nincrement(() => 42).then(result => {console.log(result)})\n\n// logs 43\nincrement(() => Promise.resolve(42)).then(result => {console.log(result)})\n
Run Code Online (Sandbox Code Playgroud)\n\n这有效。Awaitable
然而,必须为我所有使用 async/await 和 TypeScript 的项目进行指定是很烦人的。
我可以\xe2\x80\x99t真的相信这样的类型是\xe2\x80\x99t内置的,但我无法\xe2\x80\x99t找到一个。TypeScript 有内置的可等待类型吗?
\n我最近偶然发现了Python的NotImplemented
内置.经过一些阅读后,我确实得到了它的目的,但我不明白它为什么评估True
为布尔值.下面的例子让我觉得这是一种残酷的玩笑:
>>> class A:
... def __eq__(self, other):
... return NotImplemented
...
>>>
>>> a = A()
>>> a == 1
False
>>> bool(a.__eq__(1))
True
Run Code Online (Sandbox Code Playgroud)
我的问题很简单:为什么要NotImplemented
评价True
?
python ×3
angularjs ×2
node.js ×2
typescript ×2
api-doc ×1
async-await ×1
docker ×1
git ×1
html ×1
javascript ×1
monorepo ×1
npm ×1
oracle ×1
pip ×1
setuptools ×1
ubuntu ×1